machine-learning - TensorFlow 中是否有与 Matlab 中等效的 bsxfun ?

标签 machine-learning neural-network tensorflow conv-neural-network

我试图将以下 MATLAB 代码转换为 tensorflow :

WW = sum(W.^2, 1); % ( 1 x D^(l)= sum( (D^(l-1) x D^(l)), 1 )
XX = sum(A.^2, 2); % (M x 1) = sum( (M x D^(l-1)), 2 )
bsxfun(@plus, WW, XX) ; % (M x D^(l)) - (M x D^(l)) = (M x D^(l-1)) * (D^(l-1) x D^(l)) - (M x D^(l))

这是非常简单的 MATLAB 代码,我想知道 TensorFlow 中是否有等效的代码。理想情况下,W 和/或 X 应该是 tf.Variable(init) 变量,因为我想计算每个变量的导数变量。

最佳答案

Tensorflow 与 NumPy 一样,可以进行广播。

你可以做到

WW + XX

它会自己计算出尺寸

请参阅文档 here

关于machine-learning - TensorFlow 中是否有与 Matlab 中等效的 bsxfun ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37904504/

相关文章:

machine-learning - keras 中使用类权重的 U-net 的自定义损失函数 : `class_weight` not supported for 3+ dimensional targets

neural-network - 如何使用Java Encog with GA训练方法解决XOR?

python - 类型错误 : rank mismatch between coding and true distributions

python - 如何在 tf.keras 中创建具有多个输出的回归模型?

python - Windows 10 上的 TensorFlow : “not a supported wheel on this platform” error

python-3.x - 使用linerrud数据集进行感知器学习

python - 如何读取文件夹中的图像并存储其类别号和图像数据? Python

python - 使用 LSTM 进行时间序列模式识别(python)

python - 逻辑 'AND' 的 Tensorflow 自定义估计器

Python (Scikeras) - ValueError : Invalid parameter layers for estimator KerasClassifier