Last active
April 6, 2018 07:55
-
-
Save ivarreukers/ce636cd4e93d504bc3696199afd73930 to your computer and use it in GitHub Desktop.
Network
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
| protected static final long seed = 12345; | |
| protected static final int numClasses = 41; | |
| protected static final int nEpochs = 20; | |
| private static TransferLearningHelper transferLearningHelper; | |
| private static ComputationGraph vgg16transfer, vgg16; | |
| public static void main(String args[]) { | |
| ZooModel zooModel = new VGG16(); | |
| vgg16 = (ComputationGraph) zooModel.initPretrained(PretrainedType.VGGFACE); | |
| log.info(vgg16.summary()); | |
| FineTuneConfiguration fineTuneConf = new FineTuneConfiguration.Builder() | |
| .learningRate(3e-5) | |
| .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT) | |
| .updater(Updater.NESTEROVS) | |
| .seed(seed) | |
| .build(); | |
| //Construct a new model with the intended architecture and print summary | |
| vgg16transfer = new TransferLearning.GraphBuilder(vgg16) | |
| .fineTuneConfiguration(fineTuneConf) | |
| .setFeatureExtractor("fc8") //the specified layer and below are "frozen" | |
| .addLayer("predictions", | |
| new OutputLayer.Builder(LossFunctions.LossFunction.XENT) | |
| .nIn(2622).nOut(numClasses) | |
| .weightInit(WeightInit.DISTRIBUTION) | |
| .dist(new NormalDistribution(0,0.2*(2.0/(2622+numClasses)))) | |
| .activation(Activation.SIGMOID).build(), | |
| "fc8") | |
| .build(); | |
| log.info(vgg16transfer.summary()); | |
| vgg16transfer.setListeners(new StatsListener(statsStorage)); | |
| transferLearningHelper = new TransferLearningHelper(vgg16transfer); | |
| } | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Log: (First summary is of plain pretrained VGGFace net, second summary after OutputLayer is added)