Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjazdzewski1990/941a47c7b4cdfde0d0d9 to your computer and use it in GitHub Desktop.
Save pjazdzewski1990/941a47c7b4cdfde0d0d9 to your computer and use it in GitHub Desktop.
def run() = {
val input =
( 0.0 | 0.0 ) \\
( 1.0 | 0.0 ) \\
( 0.0 | 1.0 ) \\
( 1.0 | 1.0 )
val ideal =
Tuple1(0.0) \\
(1.0) \\
(1.0) \\
(0.0)
val network =
(InputLayer having bias having 2.layers) +
(ActivationSigmoid having bias having 3.layers) +
(ActivationSigmoid having 1.layers)
val procedure = input into network using (d => new ResilientPropagation(d.network, d.data)) until (_ < 0.01) giving ideal
val trainResult = procedure.get()
System.out.println("Neural Network Results for DSL:")
for { pair <- trainResult.trainingSet.getData() } {
val output = trainResult.trainedNetwork.compute(pair.getInput())
println(pair.getInput().getData(0) + "," + pair.getInput().getData(1)
+ ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
}
Encog.getInstance().shutdown()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment