Spaces:
Sleeping
Sleeping
Faster training
Browse files
app.py
CHANGED
@@ -59,16 +59,14 @@ def train(data: str, message: str):
|
|
59 |
for p in range(maxshift):
|
60 |
tokens = tokenizer.texts_to_sequences([key,])[0]
|
61 |
X.append(np.array(([0,]*p+list(tokens)+[0,]*inp_len)[:inp_len]))
|
62 |
-
|
63 |
-
output_array[dset[key]] = 1
|
64 |
-
y.append(output_array)
|
65 |
|
66 |
X = np.array(X)
|
67 |
y = np.array(y)
|
68 |
|
69 |
-
model.compile(loss="
|
70 |
|
71 |
-
model.fit(X, y, epochs=
|
72 |
model.save("cache/{data_hash}.keras")
|
73 |
tokens = tokenizer.texts_to_sequences([message,])[0]
|
74 |
prediction = model.predict(np.array([(list(tokens)+[0,]*inp_len)[:inp_len],]))[0]
|
|
|
59 |
for p in range(maxshift):
|
60 |
tokens = tokenizer.texts_to_sequences([key,])[0]
|
61 |
X.append(np.array(([0,]*p+list(tokens)+[0,]*inp_len)[:inp_len]))
|
62 |
+
y.append(dset[key])
|
|
|
|
|
63 |
|
64 |
X = np.array(X)
|
65 |
y = np.array(y)
|
66 |
|
67 |
+
model.compile(loss="sparse_categorical_crossentropy", metrics=["accuracy",])
|
68 |
|
69 |
+
model.fit(X, y, epochs=32, batch_size=8, workers=4, use_multiprocessing=True)
|
70 |
model.save("cache/{data_hash}.keras")
|
71 |
tokens = tokenizer.texts_to_sequences([message,])[0]
|
72 |
prediction = model.predict(np.array([(list(tokens)+[0,]*inp_len)[:inp_len],]))[0]
|