예제 #1
0
        public GruLayer(BinaryReader reader) : base(reader)
        {
            _bxr = NeuroWeight <T> .Load(reader.BaseStream);

            _bxz = NeuroWeight <T> .Load(reader.BaseStream);

            _bxh = NeuroWeight <T> .Load(reader.BaseStream);

            _bhr = NeuroWeight <T> .Load(reader.BaseStream);

            _bhz = NeuroWeight <T> .Load(reader.BaseStream);

            _bhh = NeuroWeight <T> .Load(reader.BaseStream);

            _wxr = NeuroWeight <T> .Load(reader.BaseStream);

            _wxz = NeuroWeight <T> .Load(reader.BaseStream);

            _wxh = NeuroWeight <T> .Load(reader.BaseStream);

            _whr = NeuroWeight <T> .Load(reader.BaseStream);

            _whz = NeuroWeight <T> .Load(reader.BaseStream);

            _whh = NeuroWeight <T> .Load(reader.BaseStream);

            _lastH      = MatrixFactory.Load <T>(reader.BaseStream);
            _hiddenOnes = Matrix <T> .Build.Dense(_hSize, _lastH.ColumnCount, Matrix <T> .One);

            RegisterWeights();
        }
예제 #2
0
        public static SequentialDataSet <T> Load(Stream stream)
        {
            using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
            {
                int count = reader.ReadInt32();
                var list  = new List <Matrix <T> >(count);

                for (int i = 0; i < count; i++)
                {
                    list.Add(MatrixFactory.Load <T>(stream));
                }

                return(new SequentialDataSet <T>(list));
            }
        }
예제 #3
0
        public static NeuroWeight <T> Load(Stream stream)
        {
            var result = new NeuroWeight <T>();

            using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
            {
                result.Weight = MatrixFactory.Load <T>(stream);
                bool saveCache = reader.ReadBoolean();
                bool saveGrad  = reader.ReadBoolean();

                if (saveCache)
                {
                    result.Cache1   = MatrixFactory.Load <T>(stream);
                    result.Cache2   = MatrixFactory.Load <T>(stream);
                    result.CacheM   = MatrixFactory.Load <T>(stream);
                    result.Timestep = reader.ReadInt32();
                }
                else
                {
                    result.Cache1 = Matrix <T> .Build.Dense(result.Weight.RowCount, result.Weight.ColumnCount);

                    result.Cache2 = Matrix <T> .Build.Dense(result.Weight.RowCount, result.Weight.ColumnCount);

                    result.CacheM = Matrix <T> .Build.Dense(result.Weight.RowCount, result.Weight.ColumnCount);
                }
                if (saveGrad)
                {
                    result.Gradient = MatrixFactory.Load <T>(stream);
                }
                else
                {
                    result.Gradient = Matrix <T> .Build.Dense(result.Weight.RowCount, result.Weight.ColumnCount);
                }
            }

            return(result);
        }
예제 #4
0
 public static Sample <T> Load(Stream stream)
 {
     return(new Sample <T>(MatrixFactory.Load <T>(stream), MatrixFactory.Load <T>(stream)));
 }