zoukankan      html  css  js  c++  java
  • 学习进度笔记

    学习进度笔记14

    卷集神经网络学习

    import tensorflow as tf

    slim = tf.contrib.slim

    def lenet(images, num_classes=10, is_training=False,

              dropout_keep_prob=0.5,

              prediction_fn=slim.softmax,

              scope='LeNet'):

      end_points = {}

      with tf.variable_scope(scope, 'LeNet', [images]):

        net = end_points['conv1'] = slim.conv2d(images, 32, [5, 5], scope='conv1')

        net = end_points['pool1'] = slim.max_pool2d(net, [2, 2], 2, scope='pool1')

        net = end_points['conv2'] = slim.conv2d(net, 64, [5, 5], scope='conv2')

        net = end_points['pool2'] = slim.max_pool2d(net, [2, 2], 2, scope='pool2')

        net = slim.flatten(net)

        end_points['Flatten'] = net

        net = end_points['fc3'] = slim.fully_connected(net, 1024, scope='fc3')

        if not num_classes:

          return net, end_points

        net = end_points['dropout3'] = slim.dropout(

            net, dropout_keep_prob, is_training=is_training, scope='dropout3')

        logits = end_points['Logits'] = slim.fully_connected(

            net, num_classes, activation_fn=None, scope='fc4')

      end_points['Predictions'] = prediction_fn(logits, scope='Predictions')

      return logits, end_points

    lenet.default_image_size = 28

    def lenet_arg_scope(weight_decay=0.0):

      """Defines the default lenet argument scope.

      Args:

        weight_decay: The weight decay to use for regularizing the model.

      Returns:

        An `arg_scope` to use for the inception v3 model.

      """

      with slim.arg_scope(

          [slim.conv2d, slim.fully_connected],

          weights_regularizer=slim.l2_regularizer(weight_decay),

          weights_initializer=tf.truncated_normal_initializer(stddev=0.1),

          activation_fn=tf.nn.relu) as sc:

        return sc

  • 相关阅读:
    Unity3D读取assetbundle
    Unity3D 发布成exe之后黑屏
    Unity3D优化总结
    Unity3D中中 rect[2] == rt->GetGLWidth() && rect[3] == rt->GetGLHeight()错误的原因及解决方法
    C# mysql 插入数据,中文乱码的解决方法
    WPF Canvas做自动缩放时获取控件的实际高度
    面向对象
    常用模块介绍
    python异常处理,多线程,多进程
    python生成器,递归调用
  • 原文地址:https://www.cnblogs.com/xueqiuxiang/p/14466981.html
Copyright © 2011-2022 走看看