【发布时间】:2018-10-31 19:36:36
【问题描述】:
在 Pytorch 中,您可以执行以下操作:
x = torch.bernoulli(my_data)
张量流中有类似的功能吗?输入可以是二维张量,比如(batch, len)吗?
我试过 tensorflow.contrib.distributions.Bernoulli:
import numpy as np
tmp_x1 = np.random.rand(20,5)
new_data_2 = tf.convert_to_tensor(tmp_x1)
from tensorflow.contrib.distributions import Bernoulli
tmp2_x1 = Bernoulli(probs=new_data_2)
出现错误:
return math_ops.log(probs) - math_ops.log1p(-1. * probs), probs
TypeError: unsupported operand type(s) for *: 'float' and 'Tensor'
【问题讨论】:
标签: python tensorflow pytorch