optimization - 将标量函数转换为 tensorflow 变量

标签 optimization machine-learning tensorflow

我正在尝试优化 tensorflow 中的一个非常复杂的函数,其中函数的最后两层是:

dist = tf.contrib.distributions.Normal(mu = self._mu_pos[0][0], sigma=self._sig[0][0])
objective = a*dist.cdf(b)

其中 ab 是标量值

但是,由于变量 objective 是一个标量,我无法使用此处定义的 train_op:

opt = tf.train.GradientDescentOptimizer(learning_rate=0.01)

train_op = opt.minimize(objective_acq,var_list = [self._input])

这是因为 opt.minimize 期望 objective 是一个 tensorflow 变量。

如何将objective转换为 tensorflow 变量?

谢谢

最佳答案

您可以使用 tf.convert_to_tensor(),请参阅文档 here .

关于optimization - 将标量函数转换为 tensorflow 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40495631/

相关文章:

python - 为什么 MNIST 图像是 1x28x28 张量?

python - 如何用Python预测第二天的股价?

python - 神经网络没有经过训练,交叉熵保持不变

linux - 属性错误 : module 'tensorflow.python.summary.summary' has no attribute 'scalar'

算法优化 : loop to find pair of items in 3D space

python-3.x - Euler 12 需要优化

c# - 内存消耗代码优化,垃圾收集器理论

php拼写检查迭代优化

statistics - 寻找一种简单的机器学习方法来从训练集中预测期末考试成绩

machine-learning - 在 Keras 中使用 Google MobileNets?