# log-scale the images if desireable
config['scaling'] = "minmax"
if "np.log" in config['scaling']:
    images = np.log1p(images)

# set tf random seed
tf.random.set_seed(config['random_seed'])
# ================== Import Data ==================
with tf.device(get_tf_device(20)):
    model = Sequential()
    model.add(Dense(2, activation='relu', input_shape=(256, )))
    model.compile(
        loss='mse',
        optimizer='adam',
    )
    print(model.summary())

    # Run experiment
    experiment = Experiment(
        model=model,
        config=config,
        model_type="regression",
        experiment_name="generate_results_energies_double_linreg",
    )
    experiment.run_kfold(
        images[double_indices],
        energies[double_indices],
    )
    experiment.save(save_model=True, save_indices=False)
    print("Finished experiment:", experiment.id)
config['scaling'] = "minmax"
if "np.log" in config['scaling']:
    images = np.log1p(images)

# set tf random seed
tf.random.set_seed(config['random_seed'])
# ================== Import Data ==================
with tf.device(get_tf_device(20)):
    padding = 'same'
    model = Sequential()
    model.add(Dense(4, activation='relu', input_shape=(256, )))
    model.compile(
        loss='mse',
        optimizer='adam',
    )
    print(model.summary())

    # Run experiment
    experiment = Experiment(
        model=model,
        config=config,
        model_type="regression",
        experiment_name="generate_results_pos_double_linreg",
    )
    experiment.run_kfold(
        images[double_indices],
        normalize_position_data(positions[double_indices]),
    )
    experiment.save(save_model=True, save_indices=False)
    print("Finished experiment:", experiment.id)
Esempio n. 3
0
tf.random.set_seed(config['random_seed'])
# ================== Import Data ==================
with tf.device(get_tf_device(20)):
    padding = 'same'
    model = Sequential()
    model.add(
        Conv2D(8, kernel_size=3, activation='relu', input_shape=(16, 16, 1),
               padding='same')
    )
    model.add(Flatten())
    model.add(Dense(2, activation='linear'))
    model.compile(
        loss='mse',
        optimizer='adam',
    )
    print(model.summary())

    # Run experiment
    experiment = Experiment(
        model=model,
        config=config,
        model_type="regression",
        experiment_name="generate_results_cnn_small",
    )
    experiment.run_kfold(
        images[single_indices],
        normalize_position_data(positions[single_indices])[:, :2],
    )
    experiment.save(save_model=True, save_indices=False)
    print("Finished experiment:", experiment.id)
Esempio n. 4
0
# log-scale the images if desireable
config['scaling'] = "minmax"
if "np.log" in config['scaling']:
    images = np.log1p(images)

# set tf random seed
tf.random.set_seed(config['random_seed'])
# ================== Import Data ==================
with tf.device(get_tf_device(20)):
    model = Sequential()
    model.add(Dense(1, activation='relu', input_shape=(256, )))
    model.compile(
        loss='mse',
        optimizer='adam',
    )
    print(model.summary())

    # Run experiment
    experiment = Experiment(
        model=model,
        config=config,
        model_type="regression",
        experiment_name="generate_results_energies_single_linreg",
    )
    experiment.run_kfold(
        images[single_indices],
        energies[single_indices, 0],
    )
    experiment.save(save_model=True, save_indices=False)
    print("Finished experiment:", experiment.id)
Esempio n. 5
0
        Conv2D(8, kernel_size=3, activation='relu', input_shape=images.shape[1:], padding='same')
    )
    model.add(Flatten())
    model.add(Dense(1, activation='sigmoid'))
    model.compile(
        optimizer='adam',
        loss='binary_crossentropy',
        metrics=['accuracy']
    )

    # Run experiment
    experiment = Experiment(
        model=model,
        config=config,
        model_type="classification",
        experiment_name="full_training_cnn_small"
    )
    experiment.run_kfold(
        images,
        labels,
    )
    experiment.save(save_model=True, save_indices=False)
    print("Finished experiment:", experiment.id)
    lpath = experiment.config['path_args']['models'] + "models.log"
    log = open(lpath,"a")
    log.write(experiment.id + ":\n")
    log.write(os.path.basename(__file__)+"\n")
    log.write(repr(config) + "\n")
    log.close()

# set tf random seed
tf.random.set_seed(config['random_seed'])
with tf.device(get_tf_device(20)):
    # Small Dense network
    model = Sequential()
    model.add(InputLayer(input_shape=(256, )))
    model.add(Dense(8, activation='relu'))
    model.add(Dense(1, activation='sigmoid'))
    model.compile(optimizer='adam',
                  loss='binary_crossentropy',
                  metrics=['accuracy'])

    # Run experiment
    experiment = Experiment(model=model,
                            config=config,
                            model_type="classification",
                            experiment_name="full_training_dense_small")
    experiment.run_kfold(
        images.reshape(images.shape[0], 256),
        labels,
    )
    experiment.save(save_model=True, save_indices=False)
    print("Finished experiment:", experiment.id)
    lpath = experiment.config['path_args']['models'] + "models.log"
    log = open(lpath, "a")
    log.write(experiment.id + ":\n")
    log.write(os.path.basename(__file__) + "\n")
    log.write(repr(config) + "\n")
    log.close()