Пример #1
0
def _fullconnect(name, input_tensor, hidden_nodes, stddev=0.04, wd=0.0, reuse=False):
    with tf.variable_scope(name, reuse=reuse) as scope:
        input_tensor_size = reduce(lambda x,y: x*y, input_tensor.get_shape()[1:].as_list())
        weights = helper._variable_with_weight_decay('weights', shape=[input_tensor_size, hidden_nodes], stddev=stddev, wd=wd)
        biases = helper._variable('biases', [hidden_nodes], tf.constant_initializer(0.0))

        reshaped = tf.reshape(input_tensor, [-1, input_tensor_size])
        output_tensor = tf.nn.xw_plus_b(reshaped, weights, biases, name=scope.name)
        if not reuse:
            helper._activation_summary(output_tensor)
    return output_tensor
Пример #2
0
def _convolution(name, input_tensor, kernel_shape, stddev=1e-4, wd=0.0, reuse=False):
    with tf.variable_scope(name, reuse=reuse) as scope:
        kernel = helper._variable_with_weight_decay("weights", shape=kernel_shape, stddev=stddev, wd=wd)
        biases = helper._variable("biases", [kernel_shape[-1]], tf.constant_initializer(0.0))

        conv = tf.nn.conv2d(input_tensor, kernel, [1, 1, 1, 1], padding="SAME")
        output_tensor = tf.nn.bias_add(conv, biases)

        if not reuse:
            helper._activation_summary(output_tensor)
            helper._multichannel_image_summary(scope.name + "/weights", kernel, perm=[3, 2, 1, 0])
    return output_tensor
Пример #3
0
def _convolution(name, input_tensor, kernel_shape, stddev=1e-4, wd=0.0, reuse=False):
    with tf.variable_scope(name, reuse=reuse) as scope:
        kernel = helper._variable_with_weight_decay('weights', shape=kernel_shape, stddev=stddev, wd=wd)
        biases = helper._variable('biases', [kernel_shape[-1]], tf.constant_initializer(0.0))

        conv = tf.nn.conv2d(input_tensor, kernel, [1, 1, 1, 1], padding='SAME')
        output_tensor = tf.nn.bias_add(conv, biases)

        if not reuse:
            helper._activation_summary(output_tensor)
            helper._multichannel_image_summary(scope.name + '/weights', kernel, perm=[3, 2, 1, 0])
    return output_tensor
Пример #4
0
def _fullconnect(name, input_tensor, hidden_nodes, stddev=0.04, wd=0.0, reuse=False):
    with tf.variable_scope(name, reuse=reuse) as scope:
        input_tensor_size = reduce(lambda x, y: x * y, input_tensor.get_shape()[1:].as_list())
        weights = helper._variable_with_weight_decay(
            "weights", shape=[input_tensor_size, hidden_nodes], stddev=stddev, wd=wd
        )
        biases = helper._variable("biases", [hidden_nodes], tf.constant_initializer(0.0))

        reshaped = tf.reshape(input_tensor, [-1, input_tensor_size])
        output_tensor = tf.nn.xw_plus_b(reshaped, weights, biases, name=scope.name)
        if not reuse:
            helper._activation_summary(output_tensor)
    return output_tensor