示例#1
0
        public double[] getPrice(int index)
        {
            CSVNormalisation normaliser = new CSVNormalisation();

            mFeedforward.calculate(index);
            double[] prices = new double[2];
            prices[0] = normaliser.deNormalise(mMinVals[mMinVals.Length - 1], mMaxVals[mMinVals.Length - 1], mFeedforward.Output);
            prices[1] = normaliser.deNormalise(mMinVals[mMinVals.Length - 1], mMaxVals[mMinVals.Length - 1],
                                               mDataSets[2][index][mDataSets[2][index].Length - 1]);
            return(prices);
        }
示例#2
0
        public void loadANN(bool reset)
        {
            List <List <double[]> > savedWeights = null;

            if (!reset)
            {
                if (File.Exists(weightFileName))
                {
                    Stream          TestFileStream = File.OpenRead(weightFileName);
                    BinaryFormatter deserializer   = new BinaryFormatter();
                    savedWeights = (List <List <double[]> >)deserializer.Deserialize(TestFileStream);
                    TestFileStream.Close();
                }
            }
            List <double[]>  normDataset  = new List <double[]>();
            List <double>    idealOutputs = new List <double>();
            CSVNormalisation normaliser   = new CSVNormalisation();

            loadData();
            normaliser.normaliseAll(mMinVals, mMaxVals, mRawData, out normDataset);
            normDataset.Shuffle();
            mDataSets = normDataset.ChunkBy(60);
            mForm.updateComboBox(mDataSets[2]);

            mNetwork = new Network();
            mNetwork.addLayer(new Layer(true, mDataSets[0][0].Length - 1));
            mNetwork.addLayer(new Layer(false, 8));
            mNetwork.addLayer(new Layer(false, 1));
            mNetwork.createStructure();
            if (savedWeights != null)
            {
                for (int i = 0; i < mNetwork.VectorLayers.Count; i++)
                {
                    mNetwork.VectorLayers[i].Weights = savedWeights[i];
                }
            }

            mFeedforward = new FeedForward(mNetwork, 0.005, mDataSets[0][0].Length - 1, 1);

            mFeedforward.DataSets = mDataSets;
        }