tf.fill()

简介: 【8月更文挑战第11天】tf.fill()。

tf.fill()
创建一个张量,用一个具体值充满张量。
tf.fill(dims, value, name=None):
dims:张量形状,同上述shape;
vlaue:张量数值;
name:名称。

代码:
fill_d = tf.fill([3,3], 8) # 2x3矩阵,元素值均为为8

查看数据

fill_d.numpy()

输出
array([[8, 8, 8],
[8, 8, 8],
[8, 8, 8]], dtype=int32)

相关文章
|
7天前
|
TensorFlow 算法框架/工具 Python
|
7月前
|
算法
shape_predictor
【6月更文挑战第19天】
94 8
|
7月前
|
机器学习/深度学习 算法 图形学
shape_predictor_68_face_landmarks
【6月更文挑战第22天】
321 7
|
7月前
|
计算机视觉 Python
shape
【6月更文挑战第10天】
96 0
The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of
The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of
1180 0
torch.fill()是怎么使用的?
torch.fill_()函数是一个in-place操作,用于将张量的所有元素设置为给定的标量值。它接受一个标量参数作为输入,该标量将用于填充整个张量。
1232 0
解决AssertionError: size of input tensor and input format are different.tensor shape: (3, 138input_for
解决AssertionError: size of input tensor and input format are different.tensor shape: (3, 138input_for
480 0
成功解决ValueError: Cannot feed value of shape (1, 10, 4) for Tensor Placeholder:0 , which has shape
成功解决ValueError: Cannot feed value of shape (1, 10, 4) for Tensor Placeholder:0 , which has shape