tf.matmul / tf.multiply
import tensorflow as tf
import numpy as np
1.tf.placeholder
placeholder()函数是在神经网络构建graph的时候在模型中的占位,此时并没有把要输入的数据传入模型,它只会分配必要的内存。
等建立session,在会话中,运行模型的时候通过feed_dict()函数向占位符喂入数据。
2.tf.session
1.tf.multiply 点乘
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
output = tf.multiply(input1, input2)
with tf.Session() as sess:
print(sess.run(output, feed_dict = {input1:[3.], input2: [4.]})) --[12.]
2.tf.matmul 矩阵相乘
x = tf.placeholder(tf.float32, shape=(3, 3))
y = tf.matmul(x, x)
with tf.Session() as sess:
#print(sess.run(y)) # ERROR:此处x还没有赋值
rand_array = np.random.rand(3, 3)
print("rand_array",rand_array)
print(sess.run(y, feed_dict={x: rand_array}))
tf.matmul / tf.multiply的更多相关文章
- tf.multiply()和tf.matmul()区别
(1)tf.multiply是点乘,即Returns x * y element-wise. (2)tf.matmul是矩阵乘法,即Multiplies matrix a by matrix b, p ...
- tf.matmul函数和tf.multiply函数
tf.matmul(a,b,transpose_a=False,transpose_b=False, adjoint_a=False, adjoint_b=False, a_is_sparse=Fal ...
- tf.matmul() 和tf.multiply() 的区别
1.tf.multiply()两个矩阵中对应元素各自相乘 格式: tf.multiply(x, y, name=None) 参数: x: 一个类型为:half, float32, float64, u ...
- tf.matmul()和tf.multipy()的区别
首先我们分析一下下面的代码: import tensorflow as tf import numpy as np a=tf.constant([[1., 2., 3.],[4., 5., 6.]]) ...
- 深度学习原理与框架-Tensorflow基本操作-mnist数据集的逻辑回归 1.tf.matmul(点乘操作) 2.tf.equal(对应位置是否相等) 3.tf.cast(将布尔类型转换为数值类型) 4.tf.argmax(返回最大值的索引) 5.tf.nn.softmax(计算softmax概率值) 6.tf.train.GradientDescentOptimizer(损失值梯度下降器)
1. tf.matmul(X, w) # 进行点乘操作 参数说明:X,w都表示输入的数据, 2.tf.equal(x, y) # 比较两个数据对应位置的数是否相等,返回值为True,或者False 参 ...
- tf.matmul()报错expected scalar type Float but found Double
tf.matmul(a,b)将矩阵a乘以矩阵b,生成a * b,这里的a,b要有相同的数据类型,否则会因为数据类型不匹配而出错. 如果出错,请看是前后分别是什么类型的,然后把数据类型进行转换.
- TF:TF下CNN实现mnist数据集预测 96%采用placeholder用法+2层C及其max_pool法+隐藏层dropout法+输出层softmax法+目标函数cross_entropy法+AdamOptimizer算法
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # number 1 to 10 ...
- TF:TF分类问题之MNIST手写50000数据集实现87.4%准确率识别:SGD法+softmax法+cross_entropy法—Jason niu
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # number 1 to 10 ...
- TF:TF之Tensorboard实践:将神经网络Tensorboard形式得到events.out.tfevents文件+dos内运行该文件本地服务器输出到网页可视化—Jason niu
import tensorflow as tf import numpy as np def add_layer(inputs, in_size, out_size, n_layer, activat ...
随机推荐
- 大数据笔记(五)——HDFS的高级特性
一.HDFS的回收站: recyclebin 1.HDFS的回收站默认是关闭的 2.启用回收站:去core-site.xml配置 路径:/root/training/hadoop-2.7.3/etc/ ...
- Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file.
w https://linux.die.net/man/1/bash bash - GNU Bourne-Again SHell Description Bash is an sh-compatibl ...
- CSS - 初始值、指定值、计算值、应用值、实际值
初始值:未提供指定值且未从父元素指定值继承的 CSS 属性的值. 指定值:通过直接声明或 CSS 属性的值. 计算值:通过需要计算得到的值,如,继承和相对的尺寸.(注意:有些计算要等到布局确定才能进行 ...
- Tensorflow | 基本函数介绍 简单详细的教程。 有用, 很棒
http://blog.csdn.net/xxzhangx/article/details/54606040 Tensorflow | 基本函数介绍 2017-01-18 23:04 1404人阅读 ...
- Java ——流(Stream)、文件(File)和IO
本节重点思维导图 示例:将指定的字符写到文件中 public static void main(String[] args) { try { //1.创建一个空的文件 File file = new ...
- UIAutomation元素识别软件
通过Python调用UIAutomation库来开发代码时,都会遇到需要识别元素的问题.笔者在这里推荐两款好用的软件:UISpy和Inspect. UISpy识别元素后,我们需要的属性有:ClassN ...
- UVa 12169 Disgruntled Judge 紫书
思路还是按照紫书,枚举a,得出b, 然后验证. 代码参考了LRJ的. #include <cstdio> #include <iostream> using namespace ...
- 69.x的平方根
class Solution: def mySqrt(self, x: int) -> int: if x < 2: return x left, right = 1, x//2 whil ...
- 如何搭建Vue环境?
搭建vue的开发环境: https://cn.vuejs.org/v2/guide/installation.html 1. 必须要安装nodejs cnpm 下载包的速度更快一些. 地址: ...
- Java学习day9面向对象编程2-方法的可变个数的参数和方法的参数传递
一.方法的可变个数的参数. 问题:我们能够打印的信息都是来源于方法的参数,也就是形参的传递.那如何要给方法传递不同的参数? .1.采用数组形参来定义方法 public static void test ...