1

I used codes from "https://github.com/IsaacChanghau/StockPrediction"

and I modified some method calls because of version diffrences. and Isaac's code result shows

"https://github.com/IsaacChanghau/StockPrediction/blob/master/predict.png"

but my Predicted result shows only constant as follows

o.d.e.r.s.p.StockPricePrediction - Predict,Actual

o.d.e.r.s.p.StockPricePrediction - 476.98651664221575,720.0900268554688
o.d.e.r.s.p.StockPricePrediction - 452.283359897887,725.27001953125
o.d.e.r.s.p.StockPricePrediction - 452.283359897887,724.1199951171875
o.d.e.r.s.p.StockPricePrediction - 452.283359897887,732.6599731445312
.......

I tried to change learningRate and updater, but it shows similar reslult.

Here is my code.

public class RecurrentNets {
   private static final double learningRate = 0.05;
   private static final int iterations = 1;
   private static final int seed = 12345;
   private static final int lstmLayer1Size = 256;
   private static final int lstmLayer2Size = 256;
   private static final int denseLayerSize = 32;
   private static final double dropoutRatio = 0.2;
   private static final int truncatedBPTTLength = 22;

   public static MultiLayerNetwork buildLstmNetworks(int nIn, int nOut) {
       MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
           .seed(seed)
           .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
           .weightInit(WeightInit.XAVIER)
           .updater(new Adam(learningRate))
           .l2(1e-4)
           .list()
           .layer(0, new GravesLSTM.Builder()
               .nIn(nIn)
               .nOut(lstmLayer1Size)
               .activation(Activation.TANH)
               .gateActivationFunction(Activation.HARDSIGMOID)
               .dropOut(dropoutRatio)
               .build())
           .layer(1, new GravesLSTM.Builder()
               .nIn(lstmLayer1Size)
               .nOut(lstmLayer2Size)
               .activation(Activation.TANH)
               .gateActivationFunction(Activation.HARDSIGMOID)
               .dropOut(dropoutRatio)
               .build())
           .layer(2, new DenseLayer.Builder()
               .nIn(lstmLayer2Size)
               .nOut(denseLayerSize)
               .activation(Activation.RELU)
               .build())
           .layer(3, new RnnOutputLayer.Builder()
               .nIn(denseLayerSize)
               .nOut(nOut)
               .activation(Activation.IDENTITY)
               .lossFunction(LossFunctions.LossFunction.MSE)
               .build())
            .backpropType(BackpropType.TruncatedBPTT)
            .tBPTTForwardLength(truncatedBPTTLength)
            .tBPTTBackwardLength(truncatedBPTTLength)
            .build();

        MultiLayerNetwork net = new MultiLayerNetwork(conf);
        net.init();
        net.setListeners(new ScoreIterationListener(100));
        return net;
    }
}

I need to change my LSTM networks to predict. please help.

Brian_Jeon
  • 11
  • 2

0 Answers0