placeholder使用

简介: placeholder使用

代码如下:

#!/usr/bin/python
import tensorflow as tf
x1 = tf.placeholder(tf.int32,shape=[1],name='x1')
x2 = tf.constant(5,name = 'x2')
result = x1 + x2
with tf.Session() as sess:
        print(sess.run(result,{x1:[3]}))

x1 定义为placeholder

x2定义为constant

  • 执行结果如下
tf.placeholder(
dtype,
shape=None,
name=None
)

dtype: The type of elements in the tensor to be fed.

shape: The shape of the tensor to be fed (optional). If the shape is not specified, you can feed a tensor of any shape.

name: A name for the operation (optional).


相关文章
|
22天前
|
JavaScript
placeholder和value的区别
placeholder和value的区别
|
6月前
|
Kubernetes 调度 异构计算
k8s Label 2
k8s Label 2
|
7月前
input输入框
input输入框
|
10月前
|
前端开发
使用 div 实现 input、textarea 输入框,并支持 placeholder 属性(解决浏览器兼容问题)
使用 div 实现 input、textarea 输入框,并支持 placeholder 属性(解决浏览器兼容问题)
117 0
|
11月前
|
JavaScript 前端开发 数据安全/隐私保护
input的23种属性
input的23种属性
|
JavaScript
input中placeholder属性
input中placeholder属性
input中placeholder属性
input checkbox 复选框大小修改
有的时候,需要使用复选框,但是复选框有时候默认的太小,这时候就需要加大复选框。 解决方法: 其实就是zoom属性,这个是放大的意思,可以设置为180%,这样就会比之前大很多。
1387 0
input placeholder 兼容性处理
input placeholder 兼容性处理
202 0
|
前端开发
使input type=“text“不可编辑
使input type=“text“不可编辑
281 0
使input type=“text“不可编辑