【发布时间】:2016-08-03 19:00:35
【问题描述】:
我正在尝试将模型参数 (W & b) 从 tensorflow 作为字典传递到 matlab。但是当我将它转换为 matlab 中的结构时,字段仍然是张量变量,我无法对它们进行所需的操作。有没有办法解决这个问题并将它们转换为双精度或矩阵?
在张量流中:
return {'W': W, 'b': b}
在matlab中:
P = py.myModelOutput(samples,labels)
model.parameters = struct(P)
然后,当我在 matlab 中打印结构时,它会显示以下内容:
ans =
W: [1x1 py.tensorflow.python.ops.variables.Variable]
b: [1x1 py.tensorflow.python.ops.variables.Variable]
尝试将字段转换为双精度也无济于事:
double(model.parameters.W)
使用双精度错误 无法从 py.tensorflow.python.ops.variables.Variable 转换为 double。
【问题讨论】:
-
您必须先使用
session.run将其转换为numpy数组
标签: python matlab data-structures tensorflow type-conversion