【发布时间】:2018-10-30 04:24:58
【问题描述】:
我想将以下 Python 代码转换为 TensorFlow 程序,但无法访问/修改矩阵元素(我在 Jupiter notebook 上运行代码)。
edges = np.matrix('0 0 0 1; 0 0 1 0; 1 0 0 0; 0 0 1 0')
mat1 = np.matrix('0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0')
for i in range(0,4):
for j in range(0,4):
if edges[i,j]==1 or (edges[i,0]==1 and edges[0,j]==1):
mat1[i,j]=1
else:
mat1[i,j]=1
print(mat1)
请帮助编写代码,以便我可以使用 TensorFlow 运行它。
【问题讨论】:
-
目前尚不清楚您期望得到什么样的帮助,但 Stack Overflow 不是免费获得软件编写的地方。
-
谢谢@Borodin。我想修改矩阵(mat1)条目,但索引在 tensorflow 中不起作用。
标签: python tensorflow machine-learning