machine-learning - 如何使用 TF 在操作计算中使用未知维度

标签 machine-learning tensorflow deep-learning theano

例如>我有一个Theano代码,它可以工作(T == Theano):

N = input.shape[0]  # input has shape wrt TF (?, num)
mse = T.sum(T.square(ytarg - ypred)) / N

如果变量 N 的维度未知,我真的不知道如何在 TF op 的计算中使用变量 N。

最佳答案

在 Tensorflow 中,您不需要知道在图形执行期间要处理的元素数量。您必须使用tf.reduce_*将此任务委托(delegate)给tensorflow操作。

Reduction

TensorFlow provides several operations that you can use to perform common math computations that reduce various dimensions of a tensor.

您在 Theano 中定义的 MSE 函数可以轻松在 Tensorlow 中定义;

mse = tf.reduce_mean(tf.pow(tf.sub(ytarg, ytarg), 2.0))

关于machine-learning - 如何使用 TF 在操作计算中使用未知维度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39316440/

相关文章:

python - 复制具有相同属性的 tensorflow 层以形成图

python - 多特征因果CNN——Keras实现

machine-learning - 为什么我的神经网络序列模型从一开始就达到 0.9998 的精度?

machine-learning - 为什么 inception net 中没有 dropout 层?

python - tensorflow 中二维数组最小值到最大值的排序

python - 在 Python 中加速矩阵 vector 乘法和求幂,可能通过调用 C/C++

math - 评估者间协议(protocol)(Fleiss 的 Kappa、Krippendorff 的 Alpha 等) Java API?

python - 如果我的 docker 镜像有 2.5GB,我会遇到什么问题以及如何减小大小?

python - 生成随机数以测试核密度估计

tensorflow - 如何使用 tensorflow 执行多标签分类以实现自动标记?