MCPcopy Create free account
hub / github.com/MorvanZhou/tutorials / add_layer

Function add_layer

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

Source from the content-addressed store, hash-verified

11
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 with tf.name_scope('layer'):
16 with tf.name_scope('weights'):
17 Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W')
18 with tf.name_scope('biases'):
19 biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b')
20 with tf.name_scope('Wx_plus_b'):
21 Wx_plus_b = tf.add(tf.matmul(inputs, Weights), biases)
22 if activation_function is None:
23 outputs = Wx_plus_b
24 else:
25 outputs = activation_function(Wx_plus_b, )
26 return outputs
27
28
29# define placeholder for inputs to network

Callers 1

full_code.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected