내 훈련 데이터입니다. keras 라이브러리를 사용하여 X_data로 'y'를 예측하고 싶습니다. 많은 시간 동안 오류가 발생했습니다. 데이터 모양에 대해 알고 있지만 잠시 멈춰 있습니다. 당신들이 도울 수 있기를 바랍니다.keras 라이브러리를 사용하여 NLP 분류를 훈련시키는 방법은 무엇입니까?
top_words = 5000
length= len(X_data)
embedding_vecor_length = 32
model = Sequential()
model.add(Embedding(embedding_vecor_length, top_words, input_length=length))
model.add(LSTM(100))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
print(model.summary())
model.fit(X_data, y, epochs=3, batch_size=32)
ValueError: Error when checking input: expected embedding_8_input to have shape (None, 24) but got array with shape (24, 1)
이 모델이 데이터를 사용의 문제는 무엇인가 :
X_data =
0 [construction, materials, labour, charges, con...
1 [catering, catering, lunch]
2 [passenger, transport, local, transport, passe...
3 [goods, transport, road, transport, goods, inl...
4 [rental, rental, aircrafts]
5 [supporting, transport, cargo, handling, agenc...
6 [postal, courier, postal, courier, local, deli...
7 [electricity, charges, reimbursement, electric...
8 [facility, management, facility, management, p...
9 [leasing, leasing, aircrafts]
10 [professional, technical, business, selling, s...
11 [telecommunications, broadcasting, information...
12 [support, personnel, search, contract, tempora...
13 [maintenance, repair, installation, maintenanc...
14 [manufacturing, physical, inputs, owned, other...
15 [accommodation, hotel, accommodation, hotel, i...
16 [leasing, rental, leasing, renting, motor, veh...
17 [real, estate, rental, leasing, involving, pro...
18 [rental, transport, vehicles, rental, road, ve...
19 [cleaning, sanitary, pad, vending, machine]
20 [royalty, transfer, use, ip, intellectual, pro...
21 [legal, accounting, legal, accounting, legal, ...
22 [veterinary, clinic, health, care, relation, a...
23 [human, health, social, care, inpatient, medic...
Name: Data, dtype: object
그리고 여기가
y =
0 1
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 10
16 2
17 10
18 2
19 2
20 10
21 10
22 10
23 10
나는이 모델을 사용하고 내 훈련 예측입니까? 입력 X_data를 사용하여 'y'를 예측하고 싶습니까?
그러나 나는 어떤 것을 다시 예측할 수 없다. 그것은 어떤 모양 오류를 보여준다. 솔직히 말해서 정말 실망 스럽습니다. 올바른 예측을하기 위해 어떤 종류의 데이터가 필요한지 말할 수 있습니까? – user169772
오류를 알지 못했거나 정확히 새로운 설정이 무엇인지 알 수 없습니다. 그래서 당신의 모델이 말하길 말하는데'model.predict()'를 실행하면 에러가 나옵니까? – DJK
필자는 텍스트의 패딩 및 인코딩 단계를 수행하여 예측을 얻었지만 출력이 이상하게 보입니다. 입력 : jelly = '서비스 요금. 6월 ' 위한 컨설팅 I 얻을 출력 : 어레이 ([0.48915482, [0.48839182, [0.49011096, [0.48880994, [0.4904303, [0.48839182, [0.48839182, .... 이 패턴은 시도한 모든 입력에 대해 0.48-0.495에 가까운 모든 입력에 대해 비슷합니다. – user169772