暗张量的张量流尺寸为0的维是什么?

时间:2019-02-16 02:47:45

标签: tensorflow

TensorShapes的尺寸可能为0,但是何时应用?你能给我一个例子吗?这让我很烦...谢谢!!

例如tf.one_hot 在实现方面,Tensorflow最终正在验证depth>= 0,这将生成尺寸为0-size的张量

import tensorflow as tf
import numpy as np

tf.enable_eager_execution()
shape = [2,2]
depth = 0
on_value = 1
off_value = 0
axis = -1
dtype = tf.int32
indices = np.random.random_integers(0, 1, shape)
value = [on_value, off_value]
out = tf.one_hot(indices, depth, on_value, off_value, axis, dtype)
print(out)

输出为tf.Tensor([],shape =(2,2,0),dtype = int32)。 但是,存在零维张量的应用场景吗?

0 个答案:

没有答案
相关问题