from cnn_toolbox import initialize_pseudo_random_number_generators,\
                        create_cnn_model,\
                        get_weights_from_conv_layer,\
                        train_cnn_complete,\
                        prepare_output_folder,\
                        save_history

# 4.1 set defined start value for random number generators?
#initialize_pseudo_random_number_generators( rnd_seed_value )

# 4.2 create the CNN
import tensorflow as tf
#with tf.device(device_name):
model = create_cnn_model(model_name="inc-nr-filters",
                         input_shape=img_shape,
                         nr_outputs=ds_train.nr_classes,
                         learn_rate=learn_rate)
model.summary()

# 4.3 plausiblity check whether the weights are really different
#     for the case, a different random seed was used
filter_weights, bias_weights = get_weights_from_conv_layer(model,
                                                           "conv2d",
                                                           show_info=True)
print("Here are filter 0 weights:")
print(filter_weights[:, :, :, 0])

# 4.4 train the CNN completely
#with tf.device(device_name):
history = train_cnn_complete(your_cnn=model,
                             your_train_ds=ds_train,
#    i.e. classification results on training and testing dataset
#    after each epoch

from cnn_toolbox import initialize_pseudo_random_number_generators,\
                        create_cnn_model,\
                        get_weights_from_conv_layer,\
                        train_cnn_complete,\
                        prepare_output_folder,\
                        save_history

# 4.1 set start value for random number generation
initialize_pseudo_random_number_generators(rnd_seed_value)

# 4.2 create the CNN
model = create_cnn_model(model_name="same_nr_filters",
                         input_shape=img_shape,
                         nr_outputs=ds_train.nr_classes)
model.summary()

# 4.3 plausiblity check whether the weights are really different
filter_weights, bias_weights = get_weights_from_conv_layer(model,
                                                           "conv2d",
                                                           show_info=True)
print("Here are filter 0 weights:")
print(filter_weights[:, :, :, 0])

# 4.4 train the CNN completely
history = train_cnn_complete(model, ds_train, ds_test, stop_epochnr=100)

# 4.5 save training history for further later analysis
output_folder = "saved_model_histories"
Beispiel #3
0
from cnn_toolbox import initialize_pseudo_random_number_generators,\
                        create_cnn_model,\
                        get_weights_from_conv_layer,\
                        train_cnn_complete,\
                        prepare_output_folder,\
                        save_history

# 4.1 set defined start value for random number generators?
#initialize_pseudo_random_number_generators( rnd_seed_value )

# 4.2 create the CNN
import tensorflow as tf
#with tf.device(device_name):
model = create_cnn_model(model_name=cnn_name,
                         input_shape=img_shape,
                         nr_outputs=ds_train.nr_classes)
model.summary()

# 4.3 plausiblity check whether the weights are really different
#     for the case, a different random seed was used
filter_weights, bias_weights = get_weights_from_conv_layer(model,
                                                           "conv2d",
                                                           show_info=True)
print("Here are filter 0 weights:")
print(filter_weights[:, :, :, 0])

# 4.4 train the CNN completely
#with tf.device(device_name):
history = train_cnn_complete(your_cnn=model,
                             your_train_ds=ds_train,