Created
June 9, 2022 13:03
-
-
Save zaleslaw/506a1606a774339720b4f78a8bd4e9f4 to your computer and use it in GitHub Desktop.
How to use mutiple callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.use { | |
it.compile( | |
optimizer = Adam(clipGradient = ClipGradientByValue(0.1f)), | |
loss = Losses.SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS, | |
metric = Metrics.ACCURACY | |
) | |
it.logSummary() | |
it.fit( | |
dataset = train, | |
epochs = EPOCHS, | |
batchSize = TRAINING_BATCH_SIZE, | |
callbacks = listOf(earlyStopping, terminateOnNaN) | |
) | |
val accuracy = it.evaluate( | |
dataset = test, | |
batchSize = TEST_BATCH_SIZE, | |
callback = EvaluateCallback() | |
).metrics[Metrics.ACCURACY] | |
val predictions = it.predict( | |
dataset = test, | |
batchSize = TEST_BATCH_SIZE, | |
callback = PredictCallback() | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment