Update train.py
Browse filesmove len(dset) into dset_size
train.py
CHANGED
@@ -9,6 +9,7 @@ from keras_self_attention import SeqSelfAttention, SeqWeightedAttention
|
|
9 |
with open("dataset.json", "r") as f:
|
10 |
dset = json.load(f)
|
11 |
|
|
|
12 |
tokenizer = Tokenizer()
|
13 |
tokenizer.fit_on_texts(list(dset.keys()))
|
14 |
|
@@ -22,6 +23,6 @@ model.add(SeqSelfAttention()) # an ATTENTION LAYER makes the model LEARN the MAI
|
|
22 |
model.add(Flatten()) # SelfAttention and the embedding layer outputs a 2D array, it's a list of words with a list of numbers for each word
|
23 |
model.add(Dense(1024, activation="relu"))
|
24 |
model.add(Dropout(0.5)) # dropout makes ___ task harder __ removing ____ information, 0.5 means delete 50% (it resets neurons to 0 so the model will truly focus on what's important, and not learn on some data that's there by accident)
|
25 |
-
model.add(Dense(
|
26 |
|
27 |
model.save("chatbot.keras") # It's obvious what it does, saves the model to a file
|
|
|
9 |
with open("dataset.json", "r") as f:
|
10 |
dset = json.load(f)
|
11 |
|
12 |
+
dset_size = len(dset)
|
13 |
tokenizer = Tokenizer()
|
14 |
tokenizer.fit_on_texts(list(dset.keys()))
|
15 |
|
|
|
23 |
model.add(Flatten()) # SelfAttention and the embedding layer outputs a 2D array, it's a list of words with a list of numbers for each word
|
24 |
model.add(Dense(1024, activation="relu"))
|
25 |
model.add(Dropout(0.5)) # dropout makes ___ task harder __ removing ____ information, 0.5 means delete 50% (it resets neurons to 0 so the model will truly focus on what's important, and not learn on some data that's there by accident)
|
26 |
+
model.add(Dense(dset_size, activation="linear")) # TBH it doesn't matter that much what activation function to use, just linear does nothing at all to the output, that might be something like softmax but i'll test that later
|
27 |
|
28 |
model.save("chatbot.keras") # It's obvious what it does, saves the model to a file
|