【发布时间】:2020-08-01 21:26:09
【问题描述】:
我正在创建一个使用 Keras 生成文本的 LSTM 模型。由于我使用的数据集(大约 25 部小说,大约 140 万字)无法一次处理(将输出转换为_Categorical()的内存问题),我创建了一个自定义生成器函数来读取数据。
# Data generator for fit and evaluate
def generator(batch_size):
start = 0
end = batch_size
while True:
x = sequences[start:end,:-1]
#print(x)
y = sequences[start:end,-1]
y = to_categorical(y, num_classes=vocab_size)
#print(y)
yield x, y
if batch_size == len(lines):
break;
else:
start += batch_size
end += batch_size
当我执行 model.fit() 方法时,在 1 个 epoch 完成训练后会抛出以下错误。
UnknownError: [_Derived_] CUDNN_STATUS_BAD_PARAM
in tensorflow/stream_executor/cuda/cuda_dnn.cc(1459): 'cudnnSetTensorNdDescriptor( tensor_desc.get(), data_type, sizeof(dims) / sizeof(dims[0]), dims, strides)'
[[{{node CudnnRNN}}]]
[[sequential/lstm/StatefulPartitionedCall]] [Op:__inference_train_function_25138]
Function call stack:
train_function -> train_function -> train_function
有谁知道如何解决这个问题?谢谢
【问题讨论】:
-
问题解决了吗?您使用的 tensorflow 版本是什么?是否可以共享可重现的代码?
标签: python tensorflow keras deep-learning