import tensorflow as tf
import tensorflow_hub as hub
hub_url = "https://hub.tensorflow.google.cn/google/tf2-preview/nnlm-en-dim128/1"
embed = hub.KerasLayer(hub_url)
embeddings = embed(["A long sentence.", "single-word", "http://example.com"])
print(embeddings.shape, embeddings.dtype)
ResourceExhaustedError:分配带有形状的张量[973771,128]并在分配器cpu [Op:RestoreV2]上的/ job:localhost / replica:0 / task:0 / device:CPU:0上键入float时,OOM
请告诉我如何解决,谢谢
答案 0 :(得分:0)
当您尝试分配NNLM模块的嵌入矩阵时,您似乎内存不足。它需要近476 MB的RAM。