<jupyter_start><jupyter_text>Alternative 1Reload a Keras-Tuner LOG_DIR.... For this, the Tuner has to instantiated exactly like in the learning phase. LOG_DIR currently not included<jupyter_code>from kerastuner.tuners import Hyperband
from kerastuner.engine.hyperparameters import HyperParameters

tuner  = Hyperband(
    build_model,
    objective = "val_accuracy",
    max_epochs=90,    
    directory = ".\Optimization_2020_04_07_121150",
    project_name='SignLagnuageModelOptimization'
    )

tuner.reload() 


best_hp = tuner.get_best_hyperparameters()[0]
model= tuner.hypermodel.build(best_hp)

history = model.fit(x_train,y_train,epochs=80,batch_size=32,validation_data=(x_val,y_val),shuffle=False)<jupyter_output><empty_output><jupyter_text>Alternative 2Load Pickle object from learning/searching phase<jupyter_code>from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession

config = ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.2
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
import pickle

tuner2= pickle.load(open("tuner_2020_04_14_225814.pkl", "rb"))
best_hp2 = tuner2.get_best_hyperparameters()[0]
model2= tuner2.hypermodel.build(best_hp2)

model2.summary()

tmp_chekpoints= "tmp\epoch{epoch:02d}-{val_accuracy:.2f}-{val_loss:.2f}.hdf5"

csv_log = tf.keras.callbacks.CSVLogger("log.csv", separator=',', append=False)
tb = tf.keras.callbacks.TensorBoard(log_dir='logs', histogram_freq=1, write_graph=True, write_images=False, update_freq='epoch', profile_batch=2, embeddings_freq=1, embeddings_metadata=None)
es = tf.keras.callbacks.EarlyStopping(monitor='val_accuracy', min_delta=0.001, patience=20, verbose=0, mode='max', baseline=None, restore_best_weights=True)
chk= tf.keras.callbacks.ModelCheckpoint(tmp_chekpoints, monitor='val_accuracy', verbose=0, save_best_only=False, save_weights_only=False, mode='max', save_freq='epoch')

history2 = model2.fit(x_train,y_train,epochs=80,batch_size=32, validation_data=(x_val,y_val),shuffle=False, verbose=2, callbacks=[chk,tb,csv_log])

import winsound
frequency = 500  # Set Frequency To 2500 Hertz
duration = 500  # Set Duration To 1000 ms == 1 second
winsound.Beep(frequency, duration)
winsound.Beep(frequency, duration)
winsound.Beep(frequency, duration)
'''
pyplot.autoscale(enable=True, axis='both', tight=None)
pyplot.plot(history.history['loss'])
pyplot.plot(history.history['val_loss'])
pyplot.title('model train vs validation loss')
pyplot.ylabel('loss')
pyplot.xlabel('epoch')
pyplot.legend(['train', 'validation'], loc='upper right')
pyplot.show()

pyplot.autoscale(enable=True, axis='both', tight=None)
pyplot.plot(history.history['accuracy'])
pyplot.plot(history.history['val_accuracy'])
pyplot.title('model train vs validation accuracy')
pyplot.ylabel('accuracy')
pyplot.xlabel('epoch')
pyplot.legend(['train', 'validation'], loc='lower right')
pyplot.show()
'''


pyplot.autoscale(enable=True, axis='both', tight=None)
pyplot.plot(history2.history['loss'])
pyplot.plot(history2.history['val_loss'])
pyplot.title('model train vs validation loss 2')
pyplot.ylabel('loss2')
pyplot.xlabel('epoch')
pyplot.legend(['train', 'validation'], loc='upper right')
pyplot.show()

pyplot.autoscale(enable=True, axis='both', tight=None)
pyplot.plot(history2.history['accuracy'])
pyplot.plot(history2.history['val_accuracy'])
pyplot.title('model train vs validation accuracy 2')
pyplot.ylabel('accuracy2')
pyplot.xlabel('epoch')
pyplot.legend(['train', 'validation'], loc='lower right')
pyplot.show()<jupyter_output><empty_output><jupyter_text>Underfit ExampleRunning this example produces a plot of train and validation loss showing the characteristic of an underfit model. In this case, performance may be improved by increasing the number of training epochs.Running this example shows the characteristic of an underfit model that appears under-provisioned.In this case, performance may be improved by increasing the capacity of the model, such as the number of memory cells in a hidden layer or number of hidden layers. Good Fit ExampleRunning the example creates a line plot showing the train and validation loss meeting.Ideally, we would like to see model performance like this if possible, although this may not be possible on challenging problems with a lot of data. Overfit ExampleRunning this example creates a plot showing the characteristic inflection point in validation loss of an overfit model.This may be a sign of too many training epochs.In this case, the model training could be stopped at the inflection point. Alternately, the number of training examples could be increased.  Evaluate<jupyter_code>#model.evaluate(x_test, y_test, verbose=2)
model2.evaluate(x_test, y_test, verbose=2)<jupyter_output><empty_output><jupyter_text>Save model<jupyter_code>model.save("sign_lang_recognition_tuned.h5")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1145769622833843, 'fraction_numerical': 0.02018348623853211, 'mean_word_length': 7.792114695340501, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '611072', 'license': 'Apache-2.0', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1559, 'n_words': 376, 'path': 'lab/Load Tuning.ipynb', 'repo_name': 'iliasprc/SignLanguageRecognition', 'size': '4905'}