Example #1
0
adam = Adam(lr=lr, beta_1=0.9, beta_2=0.999, decay=0.0)
model.compile(loss=args.loss, optimizer=adam, metrics=['accuracy'])

output = model(a)

print("Featurizer: %s" % args.featurizer)
print("\n=================================")
print("Simple Neural Network Model")
print("=================================\n")

model.summary()

print("Kernel regularizer: %s %s" % (args.kernel_regularizer, args.regularizer_param))
print("Dropout rate: %s" % args.dropout_rate)
print("Loss function: %s" % args.loss)
print("Optimizer functions: %s" % args.optimizer)
print("Number of epochs: %s" % args.epochs)
print("Learning rate: %s" % lr)
print ()

model = model_func.nn_training_history(model, X, Y, args.epochs, args.batch_size)


general.check_path_exists(save_model_path)
model_func.save_model(model, save_model_path, neural_network=1)

print("\nExiting program.")

sys.stdout.close()

Example #2
0
if method in ['simplenn']:
    neural_network = True
    if args.layer_dim == 3:
        layers_dim = [2048, 128, 8, 4]
        activation = ['relu', 'softmax', 'sigmoid']
    elif args.layer_dim == 4:
        layers_dim = [2048, 512, 128, 8, 4]
        activation = ['relu', 'tanh', 'softmax', 'sigmoid']
    elif args.layer_dim == 5:
        layers_dim = [2048, 512, 128, 16, 8, 4]
        activation = ['relu', 'tanh', 'softmax', 'tanh', 'sigmoid']
    model = model_func.define_model(method, layers_dim, activation)
elif method in ['convnn']:
    neural_network = method
    feature_length = X.shape[1]
    model = model_func.define_model(method, feature_length)
else:
    model = model_func.define_model(method, model_param)

model = model_func.train_model(model,
                               num_split,
                               seed,
                               X,
                               Y,
                               neural_network=neural_network)
if save:
    save_filepath = './saved_model/14_ecfp/' + "%s_%s_%s.h" % (
        method, args.dataset[:args.dataset.rfind('.')], args.filename_append)
    model_func.save_model(model, save_filepath, neural_network)

print("\nExiting program.")
Example #3
0
    layers_dim = [X.shape[1], 512, 128, 32, 8, Y.shape[1]]
    activation = ['relu', 'relu', 'relu', 'relu', 'sigmoid']

    epochs = args.epochs
    print("Number of epochs:", epochs)

    model_func.define_model(method)
    model = model_func.build_simplenn_model(layers_dim=layers_dim,
                                            activation=activation,
                                            loss=args.loss,
                                            optimizer=args.optimizer)

else:
    epochs = 0
    model = model_func.define_model(method, model_param)

model = model_func.train_model(model,
                               num_split,
                               seed,
                               X,
                               Y,
                               neural_network_epochs=epochs)

if args.save_model:
    save_filepath = './saved_model/' + filename + '.h'
    general.check_path_exists(save_filepath)
    model_func.save_model(model, save_filepath, epochs)

print("\nExiting program.")
sys.stdout.close()