Python 元素的数量太大
当我尝试使用tensorflow训练数据时,我遇到了这个错误 tensorflow/core/framework/op_kernel.cc:1651]op_REQUIRES在以下位置失败 gather\u nd\u op.cc:47:无效参数:params.NumElements()太大 对于int32索引:2153378304>2147483647 相关代码如下所示,对于较小的数据集,它可以正常工作。如何将其应用于更大的数据Python 元素的数量太大,python,tensorflow,Python,Tensorflow,当我尝试使用tensorflow训练数据时,我遇到了这个错误 tensorflow/core/framework/op_kernel.cc:1651]op_REQUIRES在以下位置失败 gather\u nd\u op.cc:47:无效参数:params.NumElements()太大 对于int32索引:2153378304>2147483647 相关代码如下所示,对于较小的数据集,它可以正常工作。如何将其应用于更大的数据 ml_df_collect = list() similarity
ml_df_collect = list()
similarity_input_placeholder = tf.placeholder(tf.string, shape=(None))
similarity_message_encodings = embed(similarity_input_placeholder)
with tf.Session() as session:
session.run(tf.global_variables_initializer())
session.run(tf.tables_initializer())
message_embeddings_ = session.run(
similarity_message_encodings,
feed_dict={similarity_input_placeholder: messages},
)
corr = np.inner(message_embeddings_, message_embeddings_)
ml_df_collect.append(corr)
gather\u nd
失败,因为张量对于int32
索引太大
TensorFlow文档指定gather\u nd
也可以接受int64
索引()
对索引张量使用
int64
而不是int32
可能是解决方案。如何指定int64而不是32的类型?这取决于其余代码的编写方式。例如,tf.constant([1],dtype=tf.int64)
或tf.placeholder(tf.int64)
产生int64
张量。