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)
Ejemplo n.º 2
0
def normalize(x):
    """
    Normalize a list of sample image data in the range of 0 to 1
    : x: List of image data.  The image shape is (28, 28, 1)
    : return: Numpy array of normalize data
    """
    # TODO: Implement Function

    output = np.array([image/255 for image in x])
    return output


"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_normalize(normalize)


# ### One-hot encode
# Just like the previous code cell, you'll be implementing a function for preprocessing.  This time, you'll implement the `one_hot_encode` function. The input, `x`, are a list of labels.  Implement the function to return the list of labels as One-Hot encoded Numpy array.  The possible values for labels are 0 to 9. The one-hot encoding function should return the same encoding for each value between each call to `one_hot_encode`.  Make sure to save the map of encodings outside the function.
#
# Hint: Don't reinvent the wheel. You have multiple ways to attempt this: Numpy, TF, or even sklearn's preprocessing package.

# In[ ]:


def one_hot_encode(x):
    """
    One hot encode a list of sample labels. Return a one-hot encoded vector for each label.
    : x: List of sample Labels
    : return: Numpy array of one-hot encoded labels
 def runNormalisationTests(self):
     tests.test_normalize(normalize)
     print("Model NormalisationTests Ran Successfully")
Ejemplo n.º 4
0
    """
    Normalize a list of sample image data in the range of 0 to 1
    : x: List of image data.  The image shape is (32, 32, 3)
    : return: Numpy array of normalize data
    """
    # TODO: Implement Function
    scale_max = 255
    scale_min = 0
    return (x-scale_min)/(scale_max-scale_min)
    


"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_normalize(normalize)


# ### One-hot encode
# Just like the previous code cell, you'll be implementing a function for preprocessing.  This time, you'll implement the `one_hot_encode` function. The input, `x`, are a list of labels.  Implement the function to return the list of labels as One-Hot encoded Numpy array.  The possible values for labels are 0 to 9. The one-hot encoding function should return the same encoding for each value between each call to `one_hot_encode`.  Make sure to save the map of encodings outside the function.
# 
# Hint: Don't reinvent the wheel.

# In[4]:


from sklearn import preprocessing
lb = preprocessing.LabelBinarizer()
lb.fit([0,1,2,3,4,5,6,7,8,9])

def one_hot_encode(x):
Ejemplo n.º 5
0
def test():
    tests.test_normalize(normalize)
    tests.test_one_hot_encode(one_hot_encode)