Ejemplo n.º 1
0
def random_test_with_dropout_tf():
    X, Y, Y_onehot = input_data.loadRandomData()
    layer_types = [
        'relu',
        'softmax',
    ]
    hidden_layer_dims = [
        120,
    ]
    parameters = nn_model_tf.model(X,
                                   Y_onehot,
                                   hidden_layer_dims,
                                   layer_types,
                                   learning_rate=0.5,
                                   num_iterations=2001,
                                   num_batches=2,
                                   prob=0.5)
    Y_predict, train_accuracy = nn_model_tf.predict(X, Y_onehot, parameters,
                                                    hidden_layer_dims,
                                                    layer_types)
    train_accuracy = np.sum(Y_predict == Y) / Y.shape[1]
    print('Training accuracy: %f' % train_accuracy)

    plot.show_decision_boundry(X, Y, Y_onehot, nn_model_tf.predict, parameters,
                               hidden_layer_dims, layer_types)
Ejemplo n.º 2
0
def random_test_tf():
    X, Y, Y_onehot = input_data.loadRandomData()
    layer_types = [
        'relu',
        'softmax',
    ]
    hidden_layer_dims = [
        120,
    ]
    parameters = nn_model_tf.model(X,
                                   Y_onehot,
                                   hidden_layer_dims,
                                   layer_types,
                                   learning_rate=0.5,
                                   num_iterations=1001,
                                   lambd=0)
    Y_predict, train_accuracy = nn_model_tf.predict(X, Y_onehot, parameters,
                                                    hidden_layer_dims,
                                                    layer_types)
    print('Training accuracy: %f' % train_accuracy)
    plot.show_decision_boundry(X, Y, Y_onehot, nn_model.predict, parameters,
                               hidden_layer_dims, layer_types)