Skip to content

Instantly share code, notes, and snippets.

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 StefanoSamele/f413182a5a42a6b85f3634bb7169c51d to your computer and use it in GitHub Desktop.
Save StefanoSamele/f413182a5a42a6b85f3634bb7169c51d to your computer and use it in GitHub Desktop.
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