Esempio n. 1
0
'''
ESOL data set, also known under the name "Delaney"
'''
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1' #disables GPU detection, as multithreaded BLAS on CPU is faster in most cases; remove this line to enable the use of GPUs
import sys; sys.path.append('..') #makes this script runnable from the /examples subdir without adding adding /Outer to the pythonpath

import OuterModel.train_helper as train_helper
import OuterModel.train_outer as train_outer

target_field_name = 'solubility'#'ESOL predicted log solubility in mols per litre'
input_data_csv = 'data/delaney.csv'
data_name='Delaney'

data, labels, regression, num_classes = train_helper.load_and_cache_csv(csv_file_name = input_data_csv,
                                                                 input_field_name  = 'smiles',
                                                                 target_field_name = target_field_name,
                                                                 cache_location = '../data/cached/')
xx_num_classes = labels.shape[1] if labels.ndim>1 else 1


HyperParams = {'fp_depth': 4, 'conv_width': 106, 'fp_length': 84, 'predictor_MLP_layers': [359, 359],
               'batch_normalization': False, 'initial_lr': 0.004, 'num_MLP_layers': 2,
               'training__num_epochs': 148, 'L2_reg': 3e-5}



model, train_scores, val_scores, test_scores = train_outer.perform_cross_validation(data, labels, HyperParams,
                                                                                    regression=True, num_classes=xx_num_classes,
                                                                                    initial_lr = HyperParams['initial_lr'],
                                                                                    L2_reg = HyperParams['L2_reg'],
                                                                                    use_matrix_based_implementation=False,
import sys
sys.path.append(
    '..'
)  #makes this script runnable from the /examples subdir without adding adding /Outer to the pythonpath

import OuterModel.utils as utils
import OuterModel.data_preprocessing as data_preprocessing
import OuterModel.fingerprint_model_index_based as fingerprint_model

import OuterModel.train_helper as train_helper
import OuterModel.train_outer as train_outer

#select data set (csv-file) and the columns that are used as model input and prediction target:
data, labels, regression, num_classes = train_helper.load_and_cache_csv(
    csv_file_name='../data/delaney.csv',
    input_field_name='smiles',
    target_field_name='solubility',
    cache_location='../data/cached/')
num_classes = labels.shape[1] if labels.ndim > 1 else 1

# shifts the range of regression targets to the range of [0,1] to improve the convergence of trained neural network models.
labels, undo_normalization_fn = train_helper.normalize_RegressionTargets(
    labels)

# construct the outer model. This is a "standard" Keras model with the associated methods like model.save_weights('filename') and model.load_weights('filename')
model = fingerprint_model.build_fingerprint_model(
    fp_length=84,
    fp_depth=4,
    conv_width=106,
    predictor_MLP_layers=[359, 359],
    L2_reg=3e-5,