tf.nn.embedding_lookup()
发布时间:2020-12-20 12:51:51 所属栏目:Python 来源:网络整理
导读:tf . nn . embedding_lookup ( ? ? params , ? ? ids , ? ? partition_strategy = ‘mod‘ , ? ? name = None , ? ? validate_indices = True , ? ? max_norm = None ) 功能: 选取一个张量里面索引对应的行的向量 TensorFlow链接: https://tensorflow.goog
tf.nn.embedding_lookup(
功能:选取一个张量里面索引对应的行的向量 TensorFlow链接:https://tensorflow.google.cn/api_docs/python/tf/nn/embedding_lookup?hl=en 参数:
? ? ? 举例: import numpy as np A = tf.convert_to_tensor(np.array([[[1],[2]],[[3],[4]],[[5],[6]]])) B = tf.nn.embedding_lookup(A,[[0,1],0],[0,0]]) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) print(‘A‘,sess.run(A)) print(‘A shape‘,A.shape) print(‘B‘,sess.run(B)) print(‘B shape‘,B.shape) 结果: A [[[1] [2]] [[3] [4]] [[5] [6]]] A shape (3,2,1) B [[[[1] [2]] [[3] [4]]] [[[3] [4]] [[1] [2]]] [[[1] [2]] [[1] [2]]]] B shape (3,1)
参考文献: 【1】tf.nn.embedding_lookup记录 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |