tensorflow1.3api学习笔记1(代码片段)

刘二毛 刘二毛     2022-12-13     443

关键词:

tf.layers.conv2d  卷积层

https://www.tensorflow.org/versions/r1.3/api_docs/python/tf/layers/conv2d

conv2d(
    inputs,
    filters,
    kernel_size,
    strides=(1, 1),
    padding='valid',
    data_format='channels_last',
    dilation_rate=(1, 1),
    activation=None,
    use_bias=True,
    kernel_initializer=None,
    bias_initializer=tf.zeros_initializer(),
    kernel_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    trainable=True,
    name=None,
    reuse=None
)

参数说明:

  • inputs: 输入数据.
  • filters: 卷积核. 类型和input必须相同,4维tensor, [filter_height, filter_width, in_channels, out_channels],如[5,5,3,32].
  • kernel_size: An integer or tuple/list of 2 integers, specifying the height and width of the 2D convolution window. Can be a single integer to specify the same value for all spatial dimensions.
  • strides: An integer or tuple/list of 2 integers, specifying the strides of the convolution along the height and width. Can be a single integer to specify the same value for all spatial dimensions. Specifying any stride value != 1 is incompatible with specifying any dilation_rate value != 1.
  • padding: One of "valid" or "same" (case-insensitive).
  • data_format: A string, one of channels_last (default) or channels_first. The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch, height, width, channels) while channels_first corresponds to inputs with shape (batch, channels, height, width).

  • dilation_rate: An integer or tuple/list of 2 integers, specifying the dilation rate to use for dilated convolution. Can be a single integer to specify the same value for all spatial dimensions. Currently, specifying any dilation_rate value != 1 is incompatible with specifying any stride value != 1.

  • activation: Activation function. Set it to None to maintain a linear activation.
  • use_bias: Boolean, whether the layer uses a bias.
  • kernel_initializer: An initializer for the convolution kernel.
  • bias_initializer: An initializer for the bias vector. If None, no bias will be applied.
  • kernel_regularizer: Optional regularizer for the convolution kernel.
  • bias_regularizer: Optional regularizer for the bias vector.
  • activity_regularizer: Regularizer function for the output.
  • trainable: Boolean, if True also add variables to the graph collection GraphKeys.TRAINABLE_VARIABLES (see tf.Variable).
  • name: A string, the name of the layer.
  • reuse: Boolean, whether to reuse the weights of a previous layer by the same name.

tf.layers.max_pooling2d

https://www.tensorflow.org/versions/r1.3/api_docs/python/tf/layers/max_pooling2d

max_pooling2d(
    inputs,
    pool_size,
    strides,
    padding='valid',
    data_format='channels_last',
    name=None
)

参数说明:

  • inputs: 进行池化的数据。
  • pool_size: 池化的核大小(pool_height, pool_width),如[3,3]. 如果长宽相等,也可以直接设置为一个数,如pool_size=3.
  • strides: 池化的滑动步长。可以设置为[1,1]这样的两个整数. 也可以直接设置为一个数,如strides=2
  • padding: 边缘填充,'same' 和'valid‘选其一。默认为valid
  • data_format: 输入数据格式,默认为channels_last ,即 (batch, height, width, channels),也可以设置为channels_first 对应 (batch, channels, height, width).
  • name: 层的名字

示例:

pool1=tf.layers.max_pooling2d(inputs=x, pool_size=[2, 2], strides=1)

# tf.layers.average_pooling2d是均值池化
tf.layers.dense 全连接层
https://www.tensorflow.org/versions/r1.3/api_docs/python/tf/layers/dense

dense(
    inputs,
    units,
    activation=None,
    use_bias=True,
    kernel_initializer=None,
    bias_initializer=tf.zeros_initializer(),
    kernel_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    trainable=True,
    name=None,
    reuse=None
)

  • inputs: 输入数据,2维tensor.
  • units: 该层的神经单元结点数。
  • activation: 激活函数.
  • use_bias: Boolean型,是否使用偏置项.
  • kernel_initializer: 卷积核的初始化器.
  • bias_initializer: 偏置项的初始化器,默认初始化为0.
  • kernel_regularizer: 卷积核化的正则化,可选.
  • bias_regularizer: 偏置项的正则化,可选.
  • activity_regularizer: 输出的正则化函数.
  • trainable: Boolean型,表明该层的参数是否参与训练。如果为真则变量加入到图集合中 GraphKeys.TRAINABLE_VARIABLES (see tf.Variable).
  • name: 层的名字.
  • reuse: Boolean型, 是否重复使用参数.

全连接层执行操作 outputs = activation(inputs.kernel + bias)

如果执行结果不想进行激活操作,则设置activation=None

例:

#全连接层
dense1 = tf.layers.dense(inputs=pool3, units=512, activation=tf.nn.relu)
dense2= tf.layers.dense(inputs=dense1, units=512, activation=tf.nn.relu)两个全链接

[原创]javaweb学习笔记59:struts2学习之路---ognl,值栈,读取对象栈中的对象的属性,读取contextmap里的对象的属性,调用字段和方法,数组,list,map(代码片

本博客的目的:①总结自己的学习过程,相当于学习笔记②将自己的经验分享给大家,相互学习,互相交流,不可商用内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系。本人互联网技术爱好者,... 查看详情

c语言学习笔记--数组

1.数组的概念 (1)数组是相同类型的变量的有序集合 (2)数组在一片连续的内存空间中存储元素(3)数组元素的个数可以显示或隐式指定 #include<stdio.h>intmain(){//数组初始化inta[5]={1,2};//第1、2个元素分别为1、2,... 查看详情

学习笔记(16)

1.psauxTIME是分配的时间片的总和 ps的状态 S:interruptablesleeping  D:uninterruptablesleeping T:stopped Z:zombie +:前台进程 l:多线程进程 L:内存分页并带锁 N:低优先级进程 <:高优先级进程&n 查看详情

abb800xa学习笔记49:项目框架结构1

这一片学习笔记我在新浪博客记录过,地址是ABB800XA学习笔记4:项目框架结构1_来自金沙江的小鱼_新浪博客(sina.com.cn)在这里也记录一遍,以免丢失开始第五章的学习。5.基本信息5.1目标完成此章节学习,你将能够:在800XA系统会... 查看详情

pytorch学习笔记——图像处理(transforms.normalize归一化)(代码片段)

PyTorch学习笔记——图像处理transforms.Normalize归一化回顾torchvision.ToTensor归一化transforms.Normalize公式回顾torchvision.ToTensor在看这一片博客之前,需要先浏览以下我的上一篇博客PyTorch学习笔记——图像处理(torchvision.ToTensorÿ... 查看详情

机器学习基础教程笔记---机器学习概述(代码片段)

目录机器学习概述1.1人工智能概述1.1.1机器学习与人工智能、深度学习1.1.2机器学习、深度学习能做些什么1.1.3人工智能阶段课程安排1.2什么是机器学习1.2.1定义1.2.2解释1.2.3数据集构成1.3机器学习算法分类学习目标分析1.2中的例子... 查看详情

千锋javascript学习笔记(代码片段)

千锋JavaScript学习笔记文章目录千锋JavaScript学习笔记写在前面1.JS基础1.1变量1.2数据类型1.3数据类型转换1.4运算符1.5条件1.6循环1.7函数1.8对象数据类型1.9数组和排序1.10数组常用方法:1.11字符串常用方法1.12数字常用方法1.13时间... 查看详情

机器学习随手笔记(代码片段)

信息价值IV计算案例:#_*_coding:utf-8_*_#@Time:2022/5/819:57fromnumpyimportlogfrompandasimportDataFrameasdfimportpandasaspddefcreateDateset():dataSet=[[0,1,1],[0,0,0],[0,1,0],[1,0,1],[1,0,0],[1,1 查看详情

python学习笔记(代码片段)

...1.2.继承1.3.属性设置校验1.4.定制类1.5.枚举类1.6.杂供个人学习笔记回顾时使用.1.类天下语言是一家,你抄我完,我抄他.没错,python的没啥特殊的,先来个简单的例子:classStudent(object):def__init__(self,name,score):self.name=nameself.score=scoredef... 查看详情

ts学习笔记1(代码片段)

目录TS学习笔记1安装示例TS学习笔记1安装vscode安装,code.visualstudio.comnode.js安装,nodejs.org借助npm安装tsc,npmi-gtsc终端执行tsc,权限修改,set-ExecutionPolicyRemoteSigned配置编译,这样就不用每次都tscindex.ts了;tsc 查看详情

ts学习笔记1(代码片段)

目录TS学习笔记1安装示例TS学习笔记1安装vscode安装,code.visualstudio.comnode.js安装,nodejs.org借助npm安装tsc,npmi-gtsc终端执行tsc,权限修改,set-ExecutionPolicyRemoteSigned配置编译,这样就不用每次都tscindex.ts了;tsc 查看详情

spring5学习笔记(代码片段)

文章目录Spring5学习笔记1.简介1.1介绍1.2发展历程1.3理念1.4优点1.4组成1.4.1SpringCore1.4.2SpringContext1.4.3SpringAOP1.4.4SpringDAO1.4.5SpringORM1.4.6SpringWeb1.4.7SpringWebMVC1.5扩展2.控制反转2.1原型2.1.1`UserDao`2.1.2` 查看详情

spring5学习笔记(代码片段)

文章目录Spring5学习笔记1.简介1.1介绍1.2发展历程1.3理念1.4优点1.4组成1.4.1SpringCore1.4.2SpringContext1.4.3SpringAOP1.4.4SpringDAO1.4.5SpringORM1.4.6SpringWeb1.4.7SpringWebMVC1.5扩展2.控制反转2.1原型2.1.1`UserDao`2.1.2` 查看详情

python机器学习笔记(代码片段)

Python机器学习笔记一机器学习概述1.1人工智能概述1.1.1机器学习与人工智能、深度学习关系机器学习和人工智能、深度学习的关系机器学习是人工智能的一个实现途径深度学习是机器学习的一个方法发展而来达特茅斯会议(Da... 查看详情

python机器学习笔记(代码片段)

Python机器学习笔记一机器学习概述1.1人工智能概述1.1.1机器学习与人工智能、深度学习关系机器学习和人工智能、深度学习的关系机器学习是人工智能的一个实现途径深度学习是机器学习的一个方法发展而来达特茅斯会议(Da... 查看详情

numpy学习笔记练习代码——

importnumpyasnpA=np.array([(1,‘First‘,0.5,1+2j),(2,‘Second‘,1.5,1+3j),(3,‘Third‘,0.8,1-2j)],dtype=(‘i2,a6,f4,c8‘))AOut[3]:array([(1,b‘First‘,0.5,1.+2.j),(2,b‘Second‘,1.5,1.+3.j),(3,b‘Third‘,0.80000001 查看详情

学习笔记(代码片段)

....1癌症案例附录右截断数据展示主函数参考文献0引言开始学习生存分析了,选择了StatisticalAnalysisofFailureTimeData2nd1这本书来学习。为保证学习效果。会把一些知识点以及总结发出来共同学习。水平有限,发现错误希望评论... 查看详情

matplotlib学习笔记1(代码片段)

Matplotlib学习笔记1-上手制作一些图表吧!Matplotlib是一个面向Python的,专注于数据可视化的模块。快速上手这是使用频率最高的几个模块,在接下来的程序中,都需要把它们作为基础模块importmatplotlibasmplimportmatplotlib.pyplotaspltimportn... 查看详情