MCPcopy
hub / github.com/MorvanZhou/tutorials / add_layer

Function add_layer

tensorflowTUT/tensorflow11_build_network.py:13–22  ·  view source on GitHub ↗
(inputs, in_size, out_size, activation_function=None)

Source from the content-addressed store, hash-verified

11import numpy as np
12
13def add_layer(inputs, in_size, out_size, activation_function=None):
14 # add one more layer and return the output of this layer
15 Weights = tf.Variable(tf.random_normal([in_size, out_size]))
16 biases = tf.Variable(tf.zeros([1, out_size]) + 0.1)
17 Wx_plus_b = tf.matmul(inputs, Weights) + biases
18 if activation_function is None:
19 outputs = Wx_plus_b
20 else:
21 outputs = activation_function(Wx_plus_b)
22 return outputs
23
24# Make up some real data
25x_data = np.linspace(-1,1,300)[:, np.newaxis]

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected