MCPcopy Create free account
hub / github.com/easy-tensorflow/easy-tensorflow / fc_layer

Function fc_layer

3_Neural_Network/code/ops.py:32–48  ·  view source on GitHub ↗

Create a fully-connected layer :param x: input from previous layer :param num_units: number of hidden units in the fully-connected layer :param name: layer name :param use_relu: boolean to add ReLU non-linearity (or not) :return: The output array

(x, num_units, name, use_relu=True)

Source from the content-addressed store, hash-verified

30
31
32def fc_layer(x, num_units, name, use_relu=True):
33 """
34 Create a fully-connected layer
35 :param x: input from previous layer
36 :param num_units: number of hidden units in the fully-connected layer
37 :param name: layer name
38 :param use_relu: boolean to add ReLU non-linearity (or not)
39 :return: The output array
40 """
41 in_dim = x.get_shape()[1]
42 W = weight_variable(name, shape=[in_dim, num_units])
43 b = bias_variable(name, [num_units])
44 layer = tf.matmul(x, W)
45 layer += b
46 if use_relu:
47 layer = tf.nn.relu(layer)
48 return layer

Callers 1

main.pyFile · 0.90

Calls 2

weight_variableFunction · 0.70
bias_variableFunction · 0.70

Tested by

no test coverage detected