This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # ============================================================================== | |
| # Copyright (c) Microsoft. All rights reserved. | |
| # Licensed under the MIT license. See LICENSE.md file in the project root | |
| # for full license information. | |
| # ============================================================================== | |
| # Log steps, stop on error | |
| # TODO cut down on logging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_convolutional_neural_network(input_vars, out_dims, dropout_prob=0.0): | |
| convolutional_layer_1 = Convolution((5, 5), 32, strides=1, activation=cntk.ops.relu, pad=True, init=gaussian(), init_bias=0.1)(input_vars) | |
| pooling_layer_1 = MaxPooling((2, 2), strides=(2, 2), pad=True)(convolutional_layer_1) | |
| convolutional_layer_2 = Convolution((5, 5), 64, strides=1, activation=cntk.ops.relu, pad=True, init=gaussian(), init_bias=0.1)(pooling_layer_1) | |
| pooling_layer_2 = MaxPooling((2, 2), strides=(2, 2), pad=True)(convolutional_layer_2) | |
| fully_connected_layer = Dense(1024, activation=cntk.ops.relu, init=gaussian(), init_bias=0.1)(pooling_layer_2) | |
| dropout_layer = Dropout(dropout_prob)(fully_connected_layer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| ------------------- | |
| Classification Test | |
| -------------------- | |
| ''' | |
| test_minibatch_size = 1000 | |
| sample_count = 0 | |
| test_results = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| ----------------------------------------- | |
| Training the Convolutional Neural Network | |
| ----------------------------------------- | |
| ''' | |
| num_training_epoch = 1 | |
| training_progress_output_freq = 10 | |
| for epoch in range(num_training_epoch): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| ---------------------- | |
| Setting up the trainer | |
| ---------------------- | |
| ''' | |
| # Define the label as the other input parameter of the trainer | |
| labels = cntk.ops.input_variable(output_dim, np.float32) | |
| #Initialize the parameters for the trainer | |
| train_minibatch_size = 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| --------------------------------------------- | |
| Constructing the Convolutional Neural Network | |
| --------------------------------------------- | |
| ''' | |
| def create_convolutional_neural_network(input_vars, out_dims, dropout_prob=0.0): | |
| convolutional_layer_1 = Convolution((5, 5), 32, strides=1, activation=cntk.ops.relu, pad=True)(input_vars) | |
| pooling_layer_1 = MaxPooling((2, 2), strides=(2, 2), pad=True)(convolutional_layer_1) |
NewerOlder