迪莉娅1979

关注

tf.sparse_tensor_dense_matmul 和 tf.SparseTensor 实例

迪莉娅1979

关注

阅读 166

2022-07-27


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]]


相关推荐

晗韩不普通

tensorflow tf.split 和 tf.unstack 实例

晗韩不普通 88 0 0

楠蛮鬼影

theano T.dot 实例 (是tf.matmul而不是点乘)

楠蛮鬼影 137 0 0

茗越

dense向量和稀疏向量sparse

茗越 186 0 0

罗子僧

tf.nn.max_pool 实例

罗子僧 100 0 0

是归人不是过客

tensorflow tf.where 代码实例

是归人不是过客 84 0 0

菜头粿子园

tf.dynamic_stitch 和  tf.dynamic_partition

菜头粿子园 124 0 0

夏侯居坤叶叔尘

tf.map_fn 代码实例

夏侯居坤叶叔尘 64 0 0

Silence潇湘夜雨

[tensorflow] tf.name_scope和tf.variable_scope

Silence潇湘夜雨 114 0 0

夜空一星

Tensorflow,使用tf.where编辑tensor的每个值

夜空一星 130 0 0

覃榜言

Tensorflow教程(十三) tf.Variable() 和tf.get_variable()

覃榜言 89 0 0

精彩评论(0)

0 0 举报