tf.layers.dense用法

2018年05月30日 19:09:58 o0haidee0o 阅读数:20426
 

dense:全连接层

相当于添加一个层,即初学的add_layer()函数

  1.  
    tf.layers.dense(
  2.  
        inputs,
  3.  
        units,
  4.  
        activation=None,
  5.  
        use_bias=True,
  6.  
        kernel_initializer=None,
  7.  
        bias_initializer=tf.zeros_initializer(),
  8.  
        kernel_regularizer=None,
  9.  
        bias_regularizer=None,
  10.  
        activity_regularizer=None,
  11.  
        kernel_constraint=None,
  12.  
        bias_constraint=None,
  13.  
        trainable=True,
  14.  
        name=None,
  15.  
        reuse=None
  16.  
    )

其中:

inputs: 该层的输入

units: 输出的大小(维数),整数或long

activation: 使用什么激活函数(神经网络的非线性层),默认为None,不使用激活函数

use_bias: 使用bias为True(默认使用),不用bias改成False即可

  • kernel_initializer: Initializer function for the weight matrix. If None(default), weights are initialized using the default initializer used by tf.get_variable.
  • bias_initializer: Initializer function for the bias.
  • kernel_regularizer: Regularizer function for the weight matrix.
  • bias_regularizer: Regularizer function for the bias.
  • activity_regularizer: Regularizer function for the output.
  • kernel_constraint: An optional projection function to be applied to the kernel after being updated by an Optimizer (e.g. used to implement norm constraints or value constraints for layer weights). The function must take as input the unprojected variable and must return the projected variable (which must have the same shape). Constraints are not safe to use when doing asynchronous distributed training.
  • bias_constraint: An optional projection function to be applied to the bias after being updated by an Optimizer.
  • trainable: Boolean, if True also add variables to the graph collectionGraphKeys.TRAINABLE_VARIABLES (see tf.Variable).
  • name: String, the name of the layer.
  • reuse: Boolean, whether to reuse the weights of a previous layer by the same name.

(后面懒得翻译了,有空再说吧,[微笑脸])

tf.layers.dense()的更多相关文章

  1. 对抗生成网络-图像卷积-mnist数据生成(代码) 1.tf.layers.conv2d(卷积操作) 2.tf.layers.conv2d_transpose(反卷积操作) 3.tf.layers.batch_normalize(归一化操作) 4.tf.maximum(用于lrelu) 5.tf.train_variable(训练中所有参数) 6.np.random.uniform(生成正态数据

    1. tf.layers.conv2d(input, filter, kernel_size, stride, padding) # 进行卷积操作 参数说明:input输入数据, filter特征图的 ...

  2. Tensorflow BatchNormalization详解:3_使用tf.layers高级函数来构建带有BatchNormalization的神经网络

    Batch Normalization: 使用tf.layers高级函数来构建带有Batch Normalization的神经网络 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 吴 ...

  3. Tensorflow BatchNormalization详解:2_使用tf.layers高级函数来构建神经网络

    Batch Normalization: 使用tf.layers高级函数来构建神经网络 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 吴恩达deeplearningai课程 课程笔 ...

  4. Tensorflow学习笔记(2):tf.nn.dropout 与 tf.layers.dropout

    A quick glance through tensorflow/python/layers/core.py and tensorflow/python/ops/nn_ops.pyreveals t ...

  5. tensorflow 一维卷积 tf.layers.conv1()使用

    在自然语言处理中,主要使用一维的卷积. API tf.layers.conv1d( inputs, filters, kernel_size, strides=1, padding='valid', ...

  6. TF中conv2d和kernel_initializer方法

    conv2d中的padding 在使用TF搭建CNN的过程中,卷积的操作如下 convolution = tf.nn.conv2d(X, filters, strides=[1,2,2,1], pad ...

  7. 图融合之加载子图:Tensorflow.contrib.slim与tf.train.Saver之坑

    import tensorflow as tf import tensorflow.contrib.slim as slim import rawpy import numpy as np impor ...

  8. tensorflow 1.0 学习:池化层(pooling)和全连接层(dense)

    池化层定义在 tensorflow/python/layers/pooling.py. 有最大值池化和均值池化. 1.tf.layers.max_pooling2d max_pooling2d( in ...

  9. Tensorflow BatchNormalization详解:4_使用tf.nn.batch_normalization函数实现Batch Normalization操作

    使用tf.nn.batch_normalization函数实现Batch Normalization操作 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 吴恩达deeplearnin ...

随机推荐

  1. bar

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  2. twisted的tcp.py分析

    #每个connector都有一个 Connection对象@implementer(interfaces.ITCPTransport, interfaces.ISystemHandle) class ...

  3. MySQL 中 mysqld_safe 与 mysqld 区别,以及 mysqld_safe 的使用介绍

    [mysqld_safe 与 mysqld 区别] 直接运行mysqld程序来启动MySQL服务的方法很少见 mysqld_safe脚本会在启动MySQL服务器后继续监控其运行情况,并在其死机时重新启 ...

  4. Linux 远程登录配置

    如果使用FlashFxp的sftp无法登陆,提示SSH 错误: 协商认证模式失败,也同样这样操作 修改你的ssh配置文件 配置文件路径如:/etc/ssh/sshd_config PasswordAu ...

  5. 深度学习原理与框架-卷积神经网络-cifar10分类(图片分类代码) 1.数据读入 2.模型构建 3.模型参数训练

    卷积神经网络:下面要说的这个网络,由下面三层所组成 卷积网络:卷积层 + 激活层relu+ 池化层max_pool组成 神经网络:线性变化 + 激活层relu 神经网络: 线性变化(获得得分值) 代码 ...

  6. virtualBox下Centos系统扩展LVM磁盘空间

    工具准备:下载Gparted Live CD,一个分区管理工具(根据安装的32,64位版本选择对应链接).https://sourceforge.net/projects/gparted/files/ ...

  7. sqlserver中 事物 索引及视图

      事务 1.什么是事务 事务是一个不可分割的工作逻辑单元,它包含了一组数据库的操作命令,并且所有命令作为一个整体一起向系统提交或撤销操作请求,即要么都执行,要么都不执行 2.事务的4个属性 (1). ...

  8. java web项目使用IDEA打成war包

    步骤: 1.点击 File -->Project Structure...如下图: 2.出现如下界面后点击 Artifacts--> 绿色加号-->Web Application:A ...

  9. es6 初级之展开运算符

    1.1 先看一个求最大值的例子 <!DOCTYPE html> <html lang="en"> <head> <meta charset ...

  10. 正则表达式(Python)

    课题 使用正则表达式匹配字符串 使用正则表达式 "\d{3}-(\d{4})-\d{2}" 匹配字符串 "123-4567-89" 返回匹配结果:'" ...