TF随笔-4
>>> import tensorflow as tf
>>> a=tf.constant([[1,2],[3,4]])
>>> b=tf.constant([6,6])
>>> result=tf.add(a,b)
>>> sess=tf.Session()
>>> sess.run(result)
array([[ 7, 8],
[ 9, 10]], dtype=int32)
>>> c=tf.constant([[1,2,3],[4,5,6]])
>>> result3=a*b
>>> sess.run(result3)
array([[ 6, 12],
[18, 24]], dtype=int32)>>> x1=tf.constant([[1,2],[3,4]],name="x1")
>>> x1=tf.constant([[1,2],[3,4]],name="x1")
>>> x2=tf.constant([[11,22],[33,44]],name="x2")
>>> y=tf.matmul(x1,x2)
>>> sess.run(y)
array([[ 77, 110],
[165, 242]], dtype=int32)
>>> x3=tf.constant([[10,20],],name="x3")
>>> z=tf.matmul(x3,x1)
>>> sess.run(z)
array([[ 70, 100]], dtype=int32)
#正太分布
>>> n1=tf.random_normal([2,3],mean=5,stddev=2)
#正太分布,随机值偏离平均值超过2个标准差,会重新生成新的随机数,避免产生统计学上的异常数据。
>>> n2=tf.truncated_normal([2,3],mean=6,stddev=1)
#平均分布
>>> n3=tf.random_uniform([2,3],minval=5,maxval=20)
#gamma分布
>>> n4=tf.random_gamma([2,3],alpha=1.5,beta=2.9)
>>> sess.run(n1)
array([[ 1.70361972, 0.65788937, 7.08583546],
[ 5.49968147, 2.47537422, 7.47936249]], dtype=float32)
>>> sess.run(n2)
array([[ 5.51383209, 5.28713369, 5.9794035 ],
[ 5.45024824, 6.65198326, 4.69569492]], dtype=float32)
>>> sess.run(n3)
array([[ 9.39581871, 13.13985538, 17.50672722],
[ 10.08992577, 15.1558075 , 18.60567093]], dtype=float32)
>>> sess.run(n4)
array([[ 0.3365562 , 0.27886772, 0.8982302 ],
[ 0.21223408, 0.95498532, 1.72396851]], dtype=float32)
>>> n5=tf.Variable(tf.random_normal([2,3],mean=8,stddev=2))
>>> m1=tf.zeros([2,2],tf.int32)
>>> m2=tf.ones([2,2],tf.float32)
>>> m3=tf.fill([2,2],66)
>>> sess.run(m1)
array([[0, 0],
[0, 0]], dtype=int32)
>>> sess.run(m2)
array([[ 1., 1.],
[ 1., 1.]], dtype=float32)
>>> sess.run(m3)
array([[66, 66],
[66, 66]], dtype=int32)
TF随笔-4的更多相关文章
- 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随笔-3
>>> import tensorflow as tf>>> node1 = tf.constant(3.0, dtype=tf.float32)>>& ...
随机推荐
- github-----文件项目的推拉二式
将本地项目文件推送上线: $ git init $ git add . $ git commit -m "第一次修改" $ git log $ git remote add ori ...
- python的变量类型(Day6)
Python的变量类型 变量可以指定不同的数据类型,这些变量可以存储整数,小数或字符. 变量赋值 Python 中的变量赋值不需要类型声明 等号(=)用来给变量赋值,等号左边为变量值,等号右边是存储在 ...
- s5_day8作业
# 1 整理今天装饰器代码(每人手写一份,注意,是手写,交到小组长手里,明天我检查),准备明天默写 # 2 编写日志装饰器,实现功能如:一旦函数f1执行,则将消息2017-07-21 11:12:11 ...
- springmvc RequestParam、RequestHeader
/** * 了解: * * @CookieValue: 映射一个 Cookie 值. 属性同 @RequestParam */ @RequestMapping("/testCookieVal ...
- Oracle数据安全(四)j角色管理
一.角色管理的概述 1.角色的概念 为了简化数据库权限的管理,在Oracle数据库中引入了角色的概念.所谓的角色就是一系列相关权限的集合. 2.角色的特点 在数据库中,角色的名称必须是唯一的,不能与用 ...
- Java并发之Semaphore的使用
Java并发之Semaphore的使用 一.简介 今天突然发现,看着自己喜欢的球队发挥如此的棒,然后写着博客,这种感觉很爽.现在是半场时间,就趁着这个时间的空隙,说说Java并发包中另外一个重量级的类 ...
- 安装配置zabbix代理之zabbix_proxy
配置Proxy代理 如图所示: zabbix_server端在阿里云上,其代理程序部署在各地机房,代理程序收集所在机房的所有机器监控指标,然后传给server端 环境说明: CentOS releas ...
- struts2——多文件上传
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- XMLHTTP.readyState
XMLHTTP.readyState的五种就绪状态: 0:请求未初始化(还没有调用 open()). 1:请求已经建立,但是还没有发送(还没有调用 send()). 2:请求已发送,正在处理中(通常现 ...
- Java多线程 - 线程组
Java使用ThreadGroup来表示线程组,用以对一批线程进行分类管理. Java允许程序对线程组直接进行控制,对线程组的控制相当于同时控制这批线程: 用户创建的所有线程都属于指定线程组,如果程序 ...