当前位置:网站首页>tensorflow中tf.get_variable()函数详解
tensorflow中tf.get_variable()函数详解
2022-07-29 05:21:00 【Quinn-ntmy】
如果变量存在,函数tf.get_variable()会返回现有的变量;如果变量不存在,会根据给定形状和初始值创建一个新的变量。
def get_variable(name,
shape=None,
dtype=None,
initializer=None,
regularizer=None,
trainable=True,
collections=None,
caching_device=None,
partitioner=None,
validate_shape=True,
use_resource=None,
custom_getter=None,
constraint=None)
常用参数有:
name:变量名称
shape:变量维度
initializer:变量初始化方式
regularizer:正规化
caching_device:可选的设备字符串或函数描述
还有tf.Variable()函数,
tf.Variable(initial_value=None,
trainable=True,
collections=None,
validate_shape=True,
caching_device=None,
name=None,
variable_def=None,
dtype=None,
expected_shape=None,
import_scope=None)
两者区别:
1、使用tf.Variable()时,如果检测到命名冲突,系统会自己处理。使用tf.get_variable()时,系统不会处理冲突,而会报错。
2、对于这两个函数的特性,当我们需要共享变量的时候,需要使用tf.get_variable()。在其他情况下,这两个的用法是一样的。
边栏推荐
- Interesting talk about performance optimization thread pool: is the more threads open, the better?
- 【Attention】Visual Attention Network
- 第三周周报 ResNet+ResNext
- 【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
- 【DL】关于tensor(张量)的介绍和理解
- Are you sure you know the interaction problem of activity?
- ROS教程(Xavier)
- Briefly talk about the difference between pendingintent and intent
- 并发编程学习笔记 之 工具类CountDownLatch、CyclicBarrier详解
- 【Transformer】SOFT: Softmax-free Transformer with Linear Complexity
猜你喜欢
![[network design] convnext:a convnet for the 2020s](/img/c5/fe3771aaa1c4168402bea232190a35.png)
[network design] convnext:a convnet for the 2020s

二、OCR训练时,将txt文件和图片数据转为lmdb文件格式

Ribbon learning notes 1

Tear the ORM framework by hand (generic + annotation + reflection)

【语义分割】语义分割综述

【ML】机器学习模型之PMML--概述

【Transformer】ACMix:On the Integration of Self-Attention and Convolution

通过简单的脚本在Linux环境实现Mysql数据库的定时备份(Mysqldump命令备份)

第三周周报 ResNet+ResNext

研究生新生培训第三周:ResNet+ResNeXt
随机推荐
【ML】机器学习模型之PMML--概述
clion+opencv+aruco+cmake配置
ASM piling: after learning ASM tree API, you don't have to be afraid of hook anymore
并发编程学习笔记 之 ReentrantLock实现原理的探究
MarkDown简明语法手册
[convolution kernel design] scaling up your kernels to 31x31: revising large kernel design in CNN
[semantic segmentation] Introduction to mapillary dataset
【Transformer】AdaViT: Adaptive Tokens for Efficient Vision Transformer
二、深度学习数据增强方法汇总
【Transformer】SOFT: Softmax-free Transformer with Linear Complexity
并发编程学习笔记 之 工具类CountDownLatch、CyclicBarrier详解
asyncawait和promise的区别
Ffmpeg creation GIF expression pack tutorial is coming! Say thank you, brother black fly?
【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
torch.nn.Parameter()函数理解
第2周学习:卷积神经网络基础
FFmpeg创作GIF表情包教程来了!赶紧说声多谢乌蝇哥?
Rsync+inotyfy realize real-time synchronization of single data monitoring
Spring, summer, autumn and winter with Miss Zhang (2)
MySQL inserts millions of data (using functions and stored procedures)