An example of neural networks implemented in Scala (with the jblas linear algebra library) for recognizing hand-written digits.
Requires java and sbt.
Building and running:
$ sbt run
This will run the example in src/main/scala/example/FeedForwardExample.scala
val network = NeuralNetwork(
Layer(trainSet.numInputs, 50, HyperbolicTangent):+Layer(trainSet.numOutputs, SoftMax),
objective = CrossEntropyError)
val network = NeuralNetwork(
Layer(trainSet.numInputs, 300, Logistic):+Layer(200, Logistic):+Layer(trainSet.numOutputs, SoftMax),
objective = CrossEntropyError,
weightDecay = 0.001)
val trainer = Trainer(
numIterations = 3000,
miniBatchSize = 100,
numParallel = 0, //Try using more of those cores!
learningRate = ConstantRate(0.3), //Others to try: AnnealingRate(0.35, iterations = 5000)
momentumMultiplier = 0.9,
gradientChecker = None, //To check gradients try: Some(GradientChecker(numChecks = 10, accuracy = 8))
evalIterations = 1000)
trainer.train(network, trainSet)
NeuralNetwork.save(network,"my-network.obj")
val network = NeuralNetwork.load("my-network.obj")