sentence func model work
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
This commit is contained in:
parent
cf3ede4882
commit
d077d894fb
@ -1 +1 @@
|
|||||||
╪МёКУ╘ТВэТН▒║Х∙╫√=╔в╔▓ИКЙG ▄шЁЗаБ÷Т╒(фБЕ╨≥┘юШ2
|
シⅶ喜矣ハヤリチ<EFBE98><EFBE81>フ鈺・ラ・帝<EFBDA5>G 鼓ウ愠筺<E684A0>(<28>ワェブネ<EFBE9E>2
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,3 +4,8 @@
|
|||||||
1,0,0,0,"Howdy"
|
1,0,0,0,"Howdy"
|
||||||
0,0,1,0,"What color is your hat?"
|
0,0,1,0,"What color is your hat?"
|
||||||
0,0,1,0,"Which color is your hat?"
|
0,0,1,0,"Which color is your hat?"
|
||||||
|
0,0,1,0,"What is the color is your hat?"
|
||||||
|
0,1,0,0,"My hat is Blue"
|
||||||
|
0,1,0,0,"My hat is blue"
|
||||||
|
0,1,0,0,"Your hat is Blue"
|
||||||
|
0,1,0,0,"Your hat is blue"
|
||||||
|
@ -5,3 +5,7 @@
|
|||||||
0,0,1,0,"What color is your hat?"
|
0,0,1,0,"What color is your hat?"
|
||||||
0,0,1,0,"Which color is your hat?"
|
0,0,1,0,"Which color is your hat?"
|
||||||
0,0,1,0,"What is the color is your hat?"
|
0,0,1,0,"What is the color is your hat?"
|
||||||
|
0,1,0,0,"My hat is Blue"
|
||||||
|
0,1,0,0,"My hat is blue"
|
||||||
|
0,1,0,0,"Your hat is Blue"
|
||||||
|
0,1,0,0,"Your hat is blue"
|
||||||
|
@ -27,21 +27,38 @@ from pandas import DataFrame
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MODEL CONSTANTS
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# Model constants.
|
# this is the maximum allowed size of the vocabulary
|
||||||
max_features: int = 20000
|
max_features: int = 20000
|
||||||
|
|
||||||
|
# the dimension of the output from the embedding layer
|
||||||
embedding_dim: int = 128
|
embedding_dim: int = 128
|
||||||
sequence_length: int = 500
|
|
||||||
|
# The number of epochs to train for
|
||||||
epochs: int = 50
|
epochs: int = 50
|
||||||
|
|
||||||
|
# Maximum size of the vocab for this layer
|
||||||
max_tokens: int = 5000
|
max_tokens: int = 5000
|
||||||
|
|
||||||
|
# (Only valid in INT mode) If set, the output will have its time dimension padded or truncated to exactly output_sequence_length values
|
||||||
output_sequence_length: int = 4
|
output_sequence_length: int = 4
|
||||||
|
|
||||||
|
# The number of classes we're training for
|
||||||
num_classes: int = 4
|
num_classes: int = 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
#
|
#
|
||||||
# LOAD DATA
|
# LOAD DATA
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
# read training sentences
|
# read training sentences
|
||||||
@ -73,9 +90,11 @@ test_labels: DataFrame = test_csv_raw[["utility", "transfer", "query", "imperati
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
#
|
#
|
||||||
# CREATE VECTORIZER
|
# CREATE VECTORIZER
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
# init vectorizer
|
# init vectorizer
|
||||||
@ -83,7 +102,8 @@ textVec: TextVectorization = TextVectorization(
|
|||||||
max_tokens=max_tokens,
|
max_tokens=max_tokens,
|
||||||
output_mode='int',
|
output_mode='int',
|
||||||
output_sequence_length=output_sequence_length,
|
output_sequence_length=output_sequence_length,
|
||||||
pad_to_max_tokens=True)
|
pad_to_max_tokens=True
|
||||||
|
)
|
||||||
|
|
||||||
# Add the vocab to the tokenizer
|
# Add the vocab to the tokenizer
|
||||||
textVec.adapt(vocab)
|
textVec.adapt(vocab)
|
||||||
@ -92,10 +112,11 @@ train_data: Tensor = textVec.call(input_data)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
#
|
#
|
||||||
# CREATE MODEL
|
# CREATE MODEL
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
# construct model
|
# construct model
|
||||||
@ -103,7 +124,7 @@ model: Sequential = Sequential([
|
|||||||
keras.Input(shape=(1,), dtype=tf.string),
|
keras.Input(shape=(1,), dtype=tf.string),
|
||||||
textVec,
|
textVec,
|
||||||
Embedding(max_features + 1, embedding_dim),
|
Embedding(max_features + 1, embedding_dim),
|
||||||
LSTM(64),
|
LSTM(128),
|
||||||
Dense(num_classes, activation='sigmoid')
|
Dense(num_classes, activation='sigmoid')
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -113,9 +134,11 @@ model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
#
|
#
|
||||||
# TRAIN MODEL
|
# TRAIN MODEL
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# Final formatting of data
|
# Final formatting of data
|
||||||
npTrainData = train_data_split.to_numpy(dtype=object).flatten()
|
npTrainData = train_data_split.to_numpy(dtype=object).flatten()
|
||||||
@ -131,10 +154,11 @@ model.fit(npTrainData,npTrainLabel,epochs=epochs)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
#
|
#
|
||||||
# EVALUATE MODEL
|
# EVALUATE MODEL
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
# evaluate here
|
# evaluate here
|
||||||
@ -149,7 +173,13 @@ print("Evaluating..")
|
|||||||
model.evaluate(npTestData,npTestLabel)
|
model.evaluate(npTestData,npTestLabel)
|
||||||
|
|
||||||
|
|
||||||
# predict
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# PREDICT
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# predictTargetRaw: Tensor = tf.constant(['Hello'])
|
# predictTargetRaw: Tensor = tf.constant(['Hello'])
|
||||||
# npPredict: npt.NDArray = np.array(predictTargetRaw, dtype=object)
|
# npPredict: npt.NDArray = np.array(predictTargetRaw, dtype=object)
|
||||||
# print("Prediction test..")
|
# print("Prediction test..")
|
||||||
@ -162,13 +192,21 @@ model.evaluate(npTestData,npTestLabel)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# SAVE (DEVELOPMENT) MODEL
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# save the model so keras can reload
|
# save the model so keras can reload
|
||||||
# savePath: str = './data/semantic/model.keras'
|
# savePath: str = './data/semantic/model.keras'
|
||||||
# model.save(savePath)
|
# model.save(savePath)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# SAVE MODEL
|
#
|
||||||
|
# SAVE (PRODUCTION) MODEL
|
||||||
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
# export the model so java can leverage it
|
# export the model so java can leverage it
|
||||||
@ -176,5 +214,3 @@ print("Saving..")
|
|||||||
exportPath: str = './data/model/sent_func'
|
exportPath: str = './data/model/sent_func'
|
||||||
model.export(exportPath)
|
model.export(exportPath)
|
||||||
|
|
||||||
# tf.keras.utils.get_file('asdf')
|
|
||||||
# asdf: str = 'a'
|
|
||||||
Loading…
Reference in New Issue
Block a user