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)>>& ...
随机推荐
- [Python] Send emails to the recepients specified in Message["CC"]
Recently, I'm working on a small program which needs to send emails to specific accounts. When I wan ...
- CRM项目问答总结
1. 通过ChangeList封装好多数据 DA: 在stark组件中,有五个封装的大类: class FilterOption(object): ----用于封装组合搜索的配置信息(数据库字段,是否 ...
- SqlHelper简单实现(通过Expression和反射)4.对象反射Helper类
ObjectHelper的主要功能有: 1.通过反射获取Entity的实例的字段值和表名,跳过自增键并填入Dictionary<string,string>中. namespace RA. ...
- fetch 添加请求头headers
// var headers = new Headers(); // headers.append('Authorization', localStorage.getItem('token')); f ...
- 【leetcode刷题笔记】Majority Element
Given an array of size n, find the majority element. The majority element is the element that appear ...
- Apache 工作模式配置优化
Apahce 工作模式配置 1.查看当前MPM工作模式 /usr/local/apache2/bin/apachectl -V Server version: Apache/2.4.27 (Unix) ...
- jQuery二级下拉菜单
在线演示 本地下载
- linux 查看内存信息,及其他硬件信息 dmidecode命令
由于想换内存,想看看内存型号.频率,简单搜了下命令 可以用dmidecode 命令查看. dmidecode -t memory 这个命令可以查看内存的几乎所有信息,包括频率 大小等等 另外这个命令强 ...
- MySQL-Last_Errno: 1594
故障现象 :MySQL slave所在机器自动重启,启动MySQL后,查看主从信息如下: Error_code: 1594 mysql> show slave status \G . ro ...
- C++类初始化列表
转自:https://www.cnblogs.com/BlueTzar/articles/1223169.html 构造函数初始化列表以一个冒号开始,接着是以逗号分隔的数据成员列表,每个数据成员后面跟 ...