feat: closes #40
This commit is contained in:
@@ -434,19 +434,36 @@
|
||||
{{/* TODO improve this */}}
|
||||
Training the model...<br/>
|
||||
{{/* TODO Add progress status on definitions */}}
|
||||
{{ range .Defs}}
|
||||
<div>
|
||||
<div>
|
||||
{{.Status}}
|
||||
</div>
|
||||
<div>
|
||||
{{.EpochProgress}}
|
||||
</div>
|
||||
<div>
|
||||
{{.Accuracy}}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Status
|
||||
</th>
|
||||
<th>
|
||||
EpochProgress
|
||||
</th>
|
||||
<th>
|
||||
Accuracy
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .Defs}}
|
||||
<tr>
|
||||
<td>
|
||||
{{.Status}}
|
||||
</td>
|
||||
<td>
|
||||
{{.EpochProgress}}
|
||||
</td>
|
||||
<td>
|
||||
{{.Accuracy}}
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/* TODO Add ability to stop training */}}
|
||||
</div>
|
||||
{{/* Model Ready */}}
|
||||
|
||||
@@ -93,6 +93,10 @@ val_ds = list_ds.take(val_size)
|
||||
dataset = prepare_dataset(train_ds)
|
||||
dataset_validation = prepare_dataset(val_ds)
|
||||
|
||||
|
||||
{{ if .LoadPrev }}
|
||||
model = tf.keras.saving.load_model('{{.LastModelRunPath}}')
|
||||
{{ else }}
|
||||
model = keras.Sequential([
|
||||
{{- range .Layers }}
|
||||
{{- if eq .LayerType 1}}
|
||||
@@ -106,13 +110,14 @@ model = keras.Sequential([
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
])
|
||||
{{ end }}
|
||||
|
||||
model.compile(
|
||||
loss=losses.SparseCategoricalCrossentropy(),
|
||||
optimizer=tf.keras.optimizers.Adam(),
|
||||
metrics=['accuracy'])
|
||||
|
||||
his = model.fit(dataset, validation_data= dataset_validation, epochs=50, callbacks=[NotifyServerCallback()])
|
||||
his = model.fit(dataset, validation_data= dataset_validation, epochs={{.EPOCH_PER_RUN}}, callbacks=[NotifyServerCallback()])
|
||||
|
||||
acc = his.history["accuracy"]
|
||||
|
||||
@@ -120,6 +125,6 @@ f = open("accuracy.val", "w")
|
||||
f.write(str(acc[-1]))
|
||||
f.close()
|
||||
|
||||
tf.saved_model.save(model, "model")
|
||||
|
||||
# model.save("model.keras", save_format="tf")
|
||||
tf.saved_model.save(model, "model")
|
||||
model.save("model.keras")
|
||||
|
||||
Reference in New Issue
Block a user