Keras의 SimpleRNN에서 텍스트를 학습하려고합니다. Keras에서 Keras SimpleRNN에서 input_shape가 3-d로 지정되었을 때 오류가 발생했습니다.
, 나는 다음과 같이 SimpleRNN에 대한 매우 간단한 매개 변수를 지정 : 나는 input_shape이 (nb_samples, 시간 단계, input_dim), 내 train_x.shape와 동일해야 이해model = Sequential()
model.add(SimpleRNN(output_dim=1, input_shape=(1,1,1))
그래서 나는 다음과 같은 오류가 발생했다는 것에 놀랐다.
Traceback (most recent call last):
File "C:/Users/xxx/xxxx/xxx/xxx.py", line 262, in <module>
model.add(SimpleRNN(output_dim=vocab_size, input_shape=train_x.shape))
File "C:\Anaconda3\envs\py34\lib\site-packages\keras\models.py", line 275, in add
layer.create_input_layer(batch_input_shape, input_dtype)
File "C:\Anaconda3\envs\py34\lib\site-packages\keras\engine\topology.py", line 367, in create_input_layer
self(x)
File "C:\Anaconda3\envs\py34\lib\site-packages\keras\engine\topology.py", line 467, in __call__
self.assert_input_compatibility(x)
File "C:\Anaconda3\envs\py34\lib\site-packages\keras\engine\topology.py", line 408, in assert_input_compatibility
str(K.ndim(x)))
Exception: Input 0 is incompatible with layer simplernn_1: expected ndim=3, found ndim=4
3 개만 지정되었을 때 keras가 "found ndim = 4"인 이유를 잘 모릅니다! 명확성을 위해
내
train_x.shape = (73, 84, 400)
및
vocab_size = 400
. input_shape가 3d 이상으로 공급되는 한 오류가 발생한다는 것을 깨달았습니다.
도움이 될 것입니다. :)
입니다. 당신 말이 맞아요! 이것을 이해하기 위해 잠시 나갔다! 당신의 도움을 주셔서 감사합니다!! – snowflake
@snowflake 문제가 해결되면 답변을 수락하는 것이 좋습니다. –