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)
| 30 | |
| 31 | |
| 32 | def 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 |
no test coverage detected