ResourceExhaustedError-这是由生成器或模型的问题引起的吗?

时间:2020-05-04 23:16:46

标签: python keras recurrent-neural-network

因此,我试图预测一行maxLen = 21个单词中的下一个歌词,这些单词全部转换为num_words = 31186个单词的单数组。我的最终目标是使用受过训练的模型来基于其受过训练的歌词生成新歌词。因此,我想为了做到这一点,我需要一个看起来像这样的模型。

LineGenModel = Sequential()
LineGenModel.add(
    LSTM(
        units = maxLen,
        return_sequences = True,
        input_shape = (maxLen,num_words)
    )
)
LineGenModel.add(
    Dense(
        num_words,
        activation = 'softmax'
    )
)
LineGenModel.compile(optimizer="adam", loss='categorical_crossentropy', metrics=['accuracy'])
LineGenModel.build((maxLen,num_words))
LineGenModel.summary()

我的标签值只是输入向左移动一个(即,取出输入的第一个单词,并在行尾添加eos或0)。调用我的model.fit后,我收到此错误

ResourceExhaustedError:  OOM when allocating tensor with shape[31186,84] and type float on /job:localhost/replica:0/task:0/device:CPU:0 by allocator cpu
     [[node gradients_5/zeros_like_25 (defined at c:\users\abala\appdata\local\programs\python\python38\lib\site-packages\keras\backend\tensorflow_backend.py:3007) ]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
 [Op:__inference_keras_scratch_graph_14843]

Function call stack:
keras_scratch_graph

0 个答案:

没有答案