Last active
February 3, 2024 13:36
-
-
Save dacr/4214f783f8412c2d654c9c9e05522f08 to your computer and use it in GitHub Desktop.
Playing with Java Deep Learning (DJL), tutorial-01 / published by https://github.com/dacr/code-examples-manager #15d7706b-fdc7-4aab-a788-8a2262c5d189/d9b5e10c727373c563f884b1dbc4b6318d0d3506
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
// summary : Playing with Java Deep Learning (DJL), tutorial-01 | |
// keywords : djl, machine-learning, tutorial, ai, @testable | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 15d7706b-fdc7-4aab-a788-8a2262c5d189 | |
// created-on : 2021-03-05T09:23:01Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.3.1" | |
//> using dep "org.slf4j:slf4j-api:2.0.11" | |
//> using dep "org.slf4j:slf4j-simple:2.0.11" | |
//> using dep "ai.djl:api:0.26.0" | |
// --------------------- | |
// inspired from https://docs.djl.ai/jupyter/tutorial/01_create_your_first_network.html | |
import ai.djl._ | |
import ai.djl.nn._ | |
import ai.djl.nn.core._ | |
import ai.djl.training._ | |
val application = Application.CV.IMAGE_CLASSIFICATION | |
val inputSize = 28*28 | |
val outputSize = 10 | |
val block = new SequentialBlock() | |
block.add(Blocks.batchFlattenBlock(inputSize)) | |
block.add(Linear.builder().setUnits(128).build()) | |
block.add(arr => Activation.relu(arr)) | |
block.add(Linear.builder().setUnits(64).build()) | |
block.add(arr => Activation.relu(arr)) | |
block.add(Linear.builder().setUnits(outputSize).build()) | |
println(block) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment