activation='relu', kernel_initializer=kernel_initializer, bias_initializer=bias_initializer)(model) model = Dense(4096, activation='relu', kernel_initializer=kernel_initializer, bias_initializer=bias_initializer)(model) model = Dense(num_classes, activation='softmax', kernel_initializer=kernel_initializer, bias_initializer=bias_initializer)(model) # Create model model = Model(inputs=[model_input], outputs=[model]) # Load base model's weights if model_params['base_model'] is not None: model.load_weights(os.path.join(PROJECT_HOME, model_params['base_model'])) # ------------------------------------------------- Run training ------------------------------------------------- # Initialize training API trainer = NeuralTrainer(model=model, dirs=dirs, logging_params=logging_params, pipeline_params=pipeline_params, training_params=training_params) # Run training trainer.initialize().run()
print('shape of test data after preprocessing: ', test_data) train_data = train_data.shuffle(1000) """# Saving and Recreating the trained model""" ## Save the whole model model.save('./trained_CNN/Smart_Truck/my_model_tld1.h5') ## Recreate whole model new_model=keras.models.load_model('./trained_CNN/Smart_Truck/my_model_tld1.h5') new_model.summary() ## Save the weights model.save_weights('./trained_CNN/Smart_Truck/my_weights_tld1.h5') ## Restore the weights model=create_model() model.load_weights('./trained_CNN/Smart_Truck/my_weights_tld1.h5') """# DOWNLOAD created files In this case downloading the previously created model. Steps for downloading files manually: Anzeigen -> Inhalt -> Dateien (you can also display and download everything generated). """ from google.colab import files files.download('./trained_CNN/Smart_Truck/my_model_tld1.h5')