tf随笔-1
生成新的计算图,并完成常量初始化,在新的计算 图中完成加法计算
import tensorflow as tf
g1=tf.Graph()
with g1.as_default():
value=[1.,2.,3.,4.,5.,6.]
init = tf.constant_initializer(value)
x=tf.get_variable("x",initializer=init,shape=[2,3])
y=tf.get_variable("y",shape=[2,3],initializer=tf.ones_initializer())
result=tf.add(x,y,name="myadd")
with tf.Session(graph=g1) as sess:
tf.global_variables_initializer().run()
with tf.variable_scope("",reuse=True):
print(sess.run(tf.get_variable("x")))
print(sess.run(tf.get_variable("y")))
print(sess.run(result))
输出结果
[[ 1. 2. 3.]
[ 4. 5. 6.]]
[[ 1. 1. 1.]
[ 1. 1. 1.]]
[[ 2. 3. 4.]
[ 5. 6. 7.]]
tf随笔-1的更多相关文章
- TF随笔-13
import tensorflow as tf a=tf.constant(5) b=tf.constant(3) res1=tf.divide(a,b) res2=tf.div(a,b) with ...
- TF随笔-11
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import tensorflow as tf my_var=tf.Variable(0.) step=t ...
- TF随笔-10
#!/usr/bin/env python# -*- coding: utf-8 -*-import tensorflow as tf x = tf.constant(2)y = tf.constan ...
- TF随笔-9
计算累加 #!/usr/bin/env python2 # -*- coding: utf-8 -*-"""Created on Mon Jul 24 08:25:41 ...
- TF随笔-8
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Mon Jul 10 09:35:04 201 ...
- TF随笔-7
求平均值的函数 reduce_mean axis为1表示求行 axis为0表示求列 >>> xxx=tf.constant([[1., 10.],[3.,30.]])>> ...
- tf随笔-6
import tensorflow as tfx=tf.constant([-0.2,0.5,43.98,-23.1,26.58])y=tf.clip_by_value(x,1e-10,1.0)ses ...
- tf随笔-5
# -*- coding: utf-8 -*-import tensorflow as tfw1=tf.Variable(tf.random_normal([2,6],stddev=1))w2=tf. ...
- TF随笔-4
>>> import tensorflow as tf>>> a=tf.constant([[1,2],[3,4]])>>> b=tf.const ...
- TF随笔-3
>>> import tensorflow as tf>>> node1 = tf.constant(3.0, dtype=tf.float32)>>& ...
随机推荐
- C# 创建单例你会几种方式?
关于为什么需要创建单例?这里不过多介绍,具体百度知. 关于C# 创建单例步骤或条件吧 1.声明静态变量:2.私有构造函数(无法实例化)3.静态创建实例的方法:至于我这里的Singleton是seal ...
- git分支更新代码命令
第一步: 查看状态 git status 第二步: 全部添加 git add --all 第三步: 再次查看状态 git status 第四步: 提交 git commit -m '备 ...
- WinForm下的Nhibernate+Spring.Net的框架配置文件
1.先将配置文件放到如下:<?xml version="1.0" encoding="utf-8"?> <configuration> ...
- PAT 天梯赛 L1-001 【水】
L1-001. Hello World 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 这道超级简单的题目没有任何输入. 你只需要在一行中输 ...
- BeatSaber节奏光剑插件开发官方教程2-简单的插件示例
原文:https://wiki.assistant.moe/modding/example-mod 一.在开始之前 1 确保你已经看过教你如何添加插件模板的教程,且你已经使用插件模板创建了一个新项目 ...
- 黑苹果Yosemite 10.10.1 修改wowpc.iso文件免选择直接启动Mac系统
安装教程见: http://www.cnblogs.com/zouzf/p/4356641.html 网上很多教程都是OK的,但每个人的具体情况不同就可能有一些细节问题搞死你1.本文所指的 wowpc ...
- Chemistry
Problem A. Chemistry Input file: chemistry.in Output file: chemistry.out Time limit: 1 seconds Memor ...
- Deep Auto-encoder
autoencoder可以用于数据压缩.降维,预训练神经网络,生成数据等等. autoencoder的架构 autoencoder的架构是这样的: 需要分别训练一个Encoder和一个Decoder. ...
- Spring_通过 FactoryBean 配置 Bean
beans-factorybean.xml <?xml version="1.0" encoding="UTF-8"?><beans xmln ...
- 探测web服务质量方法