当前位置: 首页>>代码示例>>Python>>正文


Python TensorflowUtils.local_response_norm方法代码示例

本文整理汇总了Python中TensorflowUtils.local_response_norm方法的典型用法代码示例。如果您正苦于以下问题:Python TensorflowUtils.local_response_norm方法的具体用法?Python TensorflowUtils.local_response_norm怎么用?Python TensorflowUtils.local_response_norm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TensorflowUtils的用法示例。


在下文中一共展示了TensorflowUtils.local_response_norm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inference

# 需要导入模块: import TensorflowUtils [as 别名]
# 或者: from TensorflowUtils import local_response_norm [as 别名]
def inference(dataset):
    with tf.name_scope("conv1") as scope:
        W1 = utils.weight_variable([5, 5, 1, 32], name="W1")
        b1 = utils.bias_variable([32], name="b1")
        tf.histogram_summary("W1", W1)
        tf.histogram_summary("b1", b1)
        h_conv1 = utils.conv2d_basic(dataset, W1, b1)
        h_norm1 = utils.local_response_norm(h_conv1)
        h_1 = tf.nn.relu(h_norm1, name="conv1")
        h_pool1 = utils.max_pool_2x2(h_1)

    with tf.name_scope("conv2") as scope:
        W2 = utils.weight_variable([3, 3, 32, 64], name="W2")
        b2 = utils.bias_variable([64], name="b2")
        tf.histogram_summary("W2", W2)
        tf.histogram_summary("b2", b2)
        h_conv2 = utils.conv2d_basic(h_pool1, W2, b2)
        h_norm2 = utils.local_response_norm(h_conv2)
        h_2 = tf.nn.relu(h_norm2, name="conv2")
        h_pool2 = utils.max_pool_2x2(h_2)

    with tf.name_scope("conv3") as scope:
        W3 = utils.weight_variable([3, 3, 64, 128], name="W3")
        b3 = utils.bias_variable([128], name="b3")
        tf.histogram_summary("W3", W3)
        tf.histogram_summary("b3", b3)
        h_conv3 = utils.conv2d_basic(h_pool2, W3, b3)
        h_norm3 = utils.local_response_norm(h_conv3)
        h_3 = tf.nn.relu(h_norm3, name="conv3")
        h_pool3 = utils.max_pool_2x2(h_3)

    with tf.name_scope("conv4") as scope:
        W4 = utils.weight_variable([3, 3, 128, 256], name="W4")
        b4 = utils.bias_variable([256], name="b4")
        tf.histogram_summary("W4", W4)
        tf.histogram_summary("b4", b4)
        h_conv4 = utils.conv2d_basic(h_pool3, W4, b4)
        h_norm4 = utils.local_response_norm(h_conv4)
        h_4 = tf.nn.relu(h_norm4, name="conv4")

    with tf.name_scope("fc1") as scope:
        image_size = IMAGE_SIZE // 8
        h_flat = tf.reshape(h_4, [-1, image_size * image_size * 256])
        W_fc1 = utils.weight_variable([image_size * image_size * 256, 512], name="W_fc1")
        b_fc1 = utils.bias_variable([512], name="b_fc1")
        tf.histogram_summary("W_fc1", W_fc1)
        tf.histogram_summary("b_fc1", b_fc1)
        h_fc1 = tf.nn.relu(tf.matmul(h_flat, W_fc1) + b_fc1)

    with tf.name_scope("fc2") as scope:
        W_fc2 = utils.weight_variable([512, NUM_LABELS], name="W_fc2")
        b_fc2 = utils.bias_variable([NUM_LABELS], name="b_fc2")
        tf.histogram_summary("W_fc2", W_fc2)
        tf.histogram_summary("b_fc2", b_fc2)
        pred = tf.matmul(h_fc1, W_fc2) + b_fc2

    return pred
开发者ID:RosieCampbell,项目名称:TensorflowProjects,代码行数:59,代码来源:FaceDetection.py

示例2: inference_res

# 需要导入模块: import TensorflowUtils [as 别名]
# 或者: from TensorflowUtils import local_response_norm [as 别名]
def inference_res(input_image):
    W1 = utils.weight_variable([3, 3, 3, 32])
    b1 = utils.bias_variable([32])
    hconv_1 = tf.nn.relu(utils.conv2d_basic(input_image, W1, b1))
    h_norm = utils.local_response_norm(hconv_1)
    bottleneck_1 = utils.bottleneck_unit(h_norm, 16, 16, down_stride=True, name="res_1")
    bottleneck_2 = utils.bottleneck_unit(bottleneck_1, 8, 8, down_stride=True, name="res_2")
    bottleneck_3 = utils.bottleneck_unit(bottleneck_2, 16, 16, up_stride=True, name="res_3")
    bottleneck_4 = utils.bottleneck_unit(bottleneck_3, 32, 32, up_stride=True, name="res_4")
    W5 = utils.weight_variable([3, 3, 32, 3])
    b5 = utils.bias_variable([3])
    out = tf.nn.tanh(utils.conv2d_basic(bottleneck_4, W5, b5))
    return out
开发者ID:RosieCampbell,项目名称:TensorflowProjects,代码行数:15,代码来源:GenerativeNeuralStyle.py


注:本文中的TensorflowUtils.local_response_norm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。