我正在使用此代码来训练新闻文章数据集。
https://github.com/borislavmavrin/stance-detection/blob/master/model_matchingLSTM_wdev.py
当我加载 GoogleNews word2vec 文件时,出现错误。
ValueError: Cannot create a tensor proto whose content is larger than 2GB.
堆栈跟踪从行 https://github.com/borislavmavrin/stance-detection/blob/master/model_matchingLSTM_wdev.py#L614 开始,
然后转到https://github.com/borislavmavrin/stance-detection/blob/master/model_matchingLSTM_wdev.py#L154
如有任何帮助,我们将不胜感激。我现在不想改变这段代码的结构,我现在只是更关注结果,因为这只是我想在这个数据集上做的原型(prototype)。如果结果足够好,我可能会编写自己的模型或改进现有模型。
最佳答案
将计算放在 CPU 上不会有帮助。这里的问题是tf.constant
的实现涉及使用 Protocol Buffer 序列化值。后者的大小限制最多为 2GB。
一种解决方法是用占位符替换常量并将值输入 sess.run()
.
您可以尝试的另一个选项是将常量分解为几个常量(拆分 numpy 数组并为每个部分创建一个 tf.constant
)并使用 tf.concat
连接它们。 。这可以在本地完成,无需稍后提供占位符。
关于python - 值错误: Cannot create a tensor proto whose content is larger than 2GB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51244489/