Skip to content

No activation function in multilayer_perceptron.py #209

@wrzadkow

Description

@wrzadkow

Hi,
there seem to be no activation functions in multilayer_perceptron.py This results in a poor performance of the network - after addition of additional ReLU at each layer (code change below), the cost almost immediately drops to ~2.3, contrary to slow convergence to ~21 for 15 batches in the current version.

current version:

def multilayer_perceptron(x):
    # Hidden fully connected layer with 256 neurons
    layer_1 = tf.add(tf.matmul(x, weights['h1']), biases['b1'])
    # Hidden fully connected layer with 256 neurons
    layer_2 = tf.add(tf.matmul(layer_1, weights['h2']), biases['b2'])
    # Output fully connected layer with a neuron for each class
    out_layer = tf.matmul(layer_2, weights['out']) + biases['out']
    return out_layer

changed into:

def multilayer_perceptron(x):
    # Hidden fully connected layer with 256 neurons
    layer_1 = tf.maximum(0.,tf.add(tf.matmul(x, weights['h1']), biases['b1']))
    # Hidden fully connected layer with 256 neurons
    layer_2 = tf.maximum(0.,tf.add(tf.matmul(layer_1, weights['h2']), biases['b2']))
    # Output fully connected layer with a neuron for each class
    out_layer = tf.maximum(0.,tf.matmul(layer_2, weights['out']) + biases['out'])
    return out_layer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions