def test_implementation(): tf.reset_default_graph() tests.test_nn_image_inputs(neural_net_image_input) tests.test_nn_label_inputs(neural_net_label_input) tests.test_nn_keep_prob_inputs(neural_net_keep_prob_input) tests.test_con_pool(conv2d_maxpool) tests.test_flatten(flatten) tests.test_fully_conn(fully_conn) tests.test_output(output) build_cnn() tests.test_conv_net(conv_net) tests.test_train_nn(train_neural_network)
def run_tests(): import problem_unittests as t t.test_folder_path(cifar10_dataset_folder_path) t.test_normalize(normalize) t.test_one_hot_encode(one_hot_encode) t.test_nn_image_inputs(neural_net_image_input) t.test_nn_label_inputs(neural_net_label_input) t.test_nn_keep_prob_inputs(neural_net_keep_prob_input) t.test_con_pool(conv2conv2d_maxpool) t.test_flatten(flatten) t.test_fully_conn(fully_conn) t.test_output(output) t.test_conv_net(conv_net) t.test_train_nn(train_neural_network)
conv = tf.nn.conv2d(x_tensor, weight, [1, conv_strides[0], conv_strides[1], 1], padding = "SAME") bias = tf.Variable(tf.zeros([conv_num_outputs])) conv = tf.nn.bias_add(conv, bias) conv = tf.nn.relu(conv) conv = tf.nn.max_pool(conv, [1, pool_ksize[0], pool_ksize[1], 1], [1, pool_strides[0], pool_strides[1], 1], padding = "SAME") return conv """ DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE """ tests.test_con_pool(conv2d_maxpool) # ### Flatten Layer # Implement the `flatten` function to change the dimension of `x_tensor` from a 4-D tensor to a 2-D tensor. The output should be the shape (*Batch Size*, *Flattened Image Size*). # # Shortcut Option: you can use classes from the [TensorFlow Layers](https://www.tensorflow.org/api_docs/python/tf/layers) or [TensorFlow Layers (contrib)](https://www.tensorflow.org/api_guides/python/contrib.layers) packages for this layer which help with some high-level features. For more of a challenge, only use other TensorFlow packages. # In[ ]: def flatten(x_tensor): """ Flatten x_tensor to (Batch Size, Flattened Image Size) : x_tensor: A tensor of size (Batch Size, ...), where ... are the image dimensions. : return: A tensor of size (Batch Size, Flattened Image Size).
mean = 0.0, stddev = 1.0/out_depth)) biases = tf.Variable(tf.zeros(conv_num_outputs)) conv_layer_out = tf.nn.bias_add(tf.nn.conv2d(x_tensor, weights, strides=[1, conv_strides[0], conv_strides[1], 1], padding='SAME'), biases) conv_layer_out = tf.nn.relu(conv_layer_out) maxpooling_out = tf.nn.max_pool(conv_layer_out, ksize=[1, pool_ksize[0], pool_ksize[1], 1], strides=[1, pool_strides[0], pool_strides[1], 1], padding='SAME') return maxpooling_out """ DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE """ tests.test_con_pool(conv2d_maxpool) # ### Flatten Layer # Implement the `flatten` function to change the dimension of `x_tensor` from a 4-D tensor to a 2-D tensor. The output should be the shape (*Batch Size*, *Flattened Image Size*). Shortcut option: you can use classes from the [TensorFlow Layers](https://www.tensorflow.org/api_docs/python/tf/layers) or [TensorFlow Layers (contrib)](https://www.tensorflow.org/api_guides/python/contrib.layers) packages for this layer. For more of a challenge, only use other TensorFlow packages. # In[9]: def flatten(x_tensor): """ Flatten x_tensor to (Batch Size, Flattened Image Size) : x_tensor: A tensor of size (Batch Size, ...), where ... are the image dimensions. : return: A tensor of size (Batch Size, Flattened Image Size). """ # TODO: Implement Function
def runConvMaxLayerTest(self): tests.test_con_pool(conv2d_maxpool) print("Model ConvMaxLayerTest Ran Successfully")