Created
August 14, 2017 12:28
-
-
Save StefanoSamele/f413182a5a42a6b85f3634bb7169c51d to your computer and use it in GitHub Desktop.
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
val height = 24 | |
val width = 24 | |
val depth = 3 | |
val img = Nd4j.ones(10, depth, height, width) | |
val reshapebuilder = new ReshapeVertex(10, 1, 36, 48) | |
private def convInit(name: String, in: Int, out: Int, kernel: Array[Int], stride: Array[Int], pad: Array[Int], bias: Double): ConvolutionLayer = | |
return new ConvolutionLayer.Builder(kernel, stride, pad).name(name).nIn(in).nOut(out).biasInit(bias).build | |
val conf: ComputationGraphConfiguration = new NeuralNetConfiguration.Builder() | |
.graphBuilder() | |
.addInputs("input") | |
.addLayer("L1", convInit("cnn1", depth, 3, Array[Int](1, 1), Array[Int](1, 1), Array[Int](0, 0), 0), "input") | |
.addVertex("L2", reshapebuilder, "L1") | |
.setOutputs("L2") | |
.build | |
val net = new ComputationGraph(conf) | |
net.init() | |
val result: Array[INDArray] = net.output(img) | |
println(result) | |
println(result(0).shapeInfoToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment