-
글쓴이글
-
2021년 3월 26일 14:52 #7506
강준구참가자import tensorflow as tf
model=tf.keras.models.Sequential([
tf.keras.layers.Embedding(len(unique_text)+1,16),
tf.keras.layers.LSTM(100,input_shape=(199425, 100)),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1,activation='softmax')
])
print(model.summary())
model.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])
model.fit(X,Y,epochs=1)여기까지 했는데요. 학습 잘 되다가 중간 쯤에 에러가 뜹니다.
짬이 안되나봅니다. 에러는 아래와 같습니다.
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
embedding (Embedding) (None, None, 16) 51376
_________________________________________________________________
lstm (LSTM) (None, 100) 46800
_________________________________________________________________
flatten (Flatten) (None, 100) 0
_________________________________________________________________
dense (Dense) (None, 1) 101
=================================================================
Total params: 98,277
Trainable params: 98,277
Non-trainable params: 0
_________________________________________________________________
None
1712/6233 [=======>......................] - ETA: 5:34 - loss: 0.4500 - accuracy: 0.7930
---------------------------------------------------------------------------InvalidArgumentError Traceback (most recent call last)
<ipython-input-18-0896385478ae> in <module>()
9 print(model.summary())
10 model.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])
---> 11 model.fit(X,Y,epochs=1)6 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
58 ctx.ensure_initialized()
59 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 60 inputs, attrs, num_outputs)
61 except core._NotOkStatusException as e:
62 if name is not None:InvalidArgumentError: indices[12,36] = 3211 is not in [0, 3211)
[[node sequential/embedding/embedding_lookup (defined at <ipython-input-18-0896385478ae>:11) ]] [Op:__inference_train_function_3139]Errors may have originated from an input operation.
Input Source operations connected to node sequential/embedding/embedding_lookup:
sequential/embedding/embedding_lookup/1927 (defined at /usr/lib/python3.7/contextlib.py:112)Function call stack:
train_function2021년 3월 26일 18:34 #7511
codingapple키 마스터중간에 에러나는건
입력한 x데이터 그니까 문자데이터 중에 내가 사전에 임베딩하지않은 문자가 있어서 그럴 확률이 90프로쯤 되는 것 같습니다
글자 전처리할 때 잘 전처리해놨는지 그리고 없는 문자는 oov로 처리했는지 다시 확인해봐야할듯요?
-
글쓴이글
- 답변은 로그인 후 가능합니다.