0
点赞
收藏
分享

微信扫一扫

tf.sparse_tensor_dense_matmul 和 tf.SparseTensor 实例

迪莉娅1979 2022-07-27 阅读 165


import tensorflow as tf

'''
[[1,0],
[0,1]]
'''
st = tf.SparseTensor(values=[1, 2], indices=[[0, 0], [1, 1]], dense_shape=[2, 2])
dt = tf.ones(shape=[2,2],dtype=tf.int32)
result = tf.sparse_tensor_dense_matmul(st,dt)
sess = tf.Session()
with sess.as_default():
print(result.eval())

print结果:
[[1 1]
[2 2]]


举报

相关推荐

0 条评论