-
-
Save tastyminerals/83cf2b6e951146771518d55a77fe30f0 to your computer and use it in GitHub Desktop.
demoNet
This file contains hidden or 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
class NetworkInit(vocabSize: Int) { | |
private val embeddingWidth = DatasetTools.getTomlConfTable("romain").getLong("inputsize").toInt | |
private val hiddenSize = DatasetTools.getTomlConfTable("romain").getLong("hiddensize").toInt | |
private val numberOfFeats = DatasetTools.getTomlConfTable("romain").getLong("feats").toInt | |
private val numberOfClasses = DatasetTools.getTomlConfTable("romain").getLong("classes").toInt | |
val config: ComputationGraphConfiguration = new NeuralNetConfiguration.Builder() | |
.learningRate(DatasetTools.getTomlConfTable("romain").getDouble("minlr")) | |
.graphBuilder() | |
.addInputs("wordIndeces") | |
.addInputs("features") | |
.addLayer("wordVectorizer", | |
new EmbeddingLayer.Builder() | |
.nIn(vocabSize) | |
.nOut(embeddingWidth) | |
.build(), | |
"wordIndeces") | |
.addLayer("linear1", | |
new DenseLayer.Builder() | |
.nIn(numberOfFeats) | |
.nOut(embeddingWidth) | |
.build(), | |
"features") | |
.addVertex("sum", new ElementWiseVertex(ElementWiseVertex.Op.Add), "wordVectorizer", "linear1") | |
.addLayer("hidden", | |
new GravesLSTM.Builder() | |
.activation(Activation.TANH) | |
.nIn(hiddenSize) | |
.nOut(hiddenSize) | |
.build(), | |
"sum") | |
.addLayer("linear2", | |
new DenseLayer.Builder() | |
.activation(Activation.SIGMOID) // only if numberOfClasses == 1 | |
//.activation(Activation.SOFTMAX) // use if numberOfClasses > 1 | |
.nIn(hiddenSize) | |
.nOut(numberOfClasses) | |
.build(), | |
"hidden") | |
.setOutputs("linear2") | |
.build() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment