I'm working on a classification task, trying to reconstruct a network from paper. In that paper, they are talking about doing a train test split 300 times and training the network each time after they are taking the mean of all predictions from each network for specific input data.
So here's the question: After the first evaluation it's skipping all the others because the evaluation of the last epoch of the first training is always better than the first epoch evaluation of the next network training, what can I do to compare the last epochs of networks?
Here's the code:
checkpoint_filepath = './checkpoint'
model_checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
filepath=checkpoint_filepath,
save_weights_only=True,
monitor='precision',
mode='max',
save_best_only=True)
lis = []
for i in range(300):
# Train test split
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.3, stratify = Y)
# Create model
model_two_neuron = tf.keras.Sequential([
tf.keras.layers.Dense(40, input_shape=(15,)),
tf.keras.layers.Dense(2, activation=tf.nn.sigmoid)
])
model_two_neuron.compile(optimizer=tf.keras.optimizers.Adam(),
loss=tf.keras.losses.MeanSquaredError(),
metrics=[tf.keras.metrics.Precision()])
# Train
model_two_neuron.fit(X_train, y_train, epochs=20, callbacks=[model_checkpoint_callback])
# evaluate
value = model_two_neuron.evaluate(X_test, y_test)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…