示例#1
0
                              num_iterations=0,
                              large_input_bool=False):
    # Training a Neural Network to classify the data
    layers = Layers(data.D, data.K)
    if len(num_neurons) == 0:
        num_neurons = 10  # default to a single hidden layer with 10 neurons
    for hidden_set in num_neurons:
        layers.add_layer(num_neurons)
    if num_iterations > 0:
        neural_network = NeuralNetwork(data, layers, num_iterations)
    else:
        neural_network = NeuralNetwork(data, layers)
    neural_network.train(large_input_bool)
    accuracy = neural_network.evaluate()
    print accuracy


if __name__ == '__main__':
    toy_2d_data = Data()
    toy_2d_data.construct_toy_data()
    toy_2d_data.preprocess()  # No actual need for preprocessing here.
    '''
    # Visualizing the data
    X, y = toy_2d_data.X, toy_2d_data.y
    plt.scatter(X[:, 0], X[:, 1], c=y, s=40, cmap=plt.cm.Spectral)
    plt.show()
    '''

    # classifyWithSoftmax(toy_2d_data)
    classifyWithNeuralNetwork(toy_2d_data, num_neurons=100)