我在一个简单的CNN keras模型中内存不足。下面是模型摘要:
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv1d (Conv1D) (None, 398, 250) 225250
global_max_pooling1d (Globa (None, 250) 0
lMaxPooling1D)
dense (Dense) (None, 250) 62750
dropout (Dropout) (None, 250) 0
activation (Activation) (None, 250) 0
dense_1 (Dense) (None, 1) 251
activation_1 (Activation) (None, 1) 0
=================================================================
Total params: 288,251
Trainable params: 288,251
Non-trainable params: 0
_________________________________________________________________
我有一个20,000 x 400 x 300的嵌入矩阵作为x_train输入(python嵌套列表),所有的值都是np.float16(总大小小于5GB)。
model.fit(x_train, y_train,
batch_size=32,
epochs=2,
verbose=1,
validation_data=(x_test, y_test),)
Colab崩溃并显示消息“您的内存不足”。它甚至没有开始输出详细消息。
1条答案
按热度按时间7kjnsjlb1#
您应该尝试使用较小的
batch_size
,您可以从4这样的小值开始,如果您的内存没有崩溃,请尝试将其递增为8、16