예제 #1
0
 public FCNetwork(FCNetworkConfig config)
 {
     Inputs = new NativeArray <float>(config.Layers[0].NumNeurons, Allocator.Persistent);
     Layers = new FCLayer[config.Layers.Count - 1];
     for (int l = 0; l < Layers.Length; l++)
     {
         Layers[l] = new FCLayer(config.Layers[l + 1].NumNeurons, config.Layers[l].NumNeurons);
     }
     Config = config;
 }
예제 #2
0
        public FCGradients(FCNetworkConfig config)
        {
            Layers = new FCGradientsLayer[config.Layers.Count - 1];
            for (int l = 0; l < Layers.Length; l++)
            {
                Layers[l] = new FCGradientsLayer(config.Layers[l + 1].NumNeurons, config.Layers[l].NumNeurons);
            }

            DCDO   = new NativeArray <float>(config.Layers[config.Layers.Count - 1].NumNeurons, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            Config = config;
        }
예제 #3
0
        private void Awake()
        {
            Application.runInBackground = true;

            DataManager.Load();

            _rng = new Rng(1234);

            var config = new FCNetworkConfig();

            config.Layers.Add(new FCLayerConfig {
                NumNeurons = DataManager.ImgDims * DataManager.Channels
            });
            config.Layers.Add(new FCLayerConfig {
                NumNeurons = 40
            });
            config.Layers.Add(new FCLayerConfig {
                NumNeurons = 20
            });
            config.Layers.Add(new FCLayerConfig {
                NumNeurons = 10
            });

            _net = new FCNetwork(config);
            NeuralUtils.Initialize(_net, ref _rng);

            _gradients    = new FCGradients(config);
            _gradientsAvg = new FCGradients(config);

            _batch         = new NativeArray <int>(BatchSize, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _targetOutputs = new NativeArray <float>(OutputClassCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            _dCdO          = new NativeArray <float>(OutputClassCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            _watch = System.Diagnostics.Stopwatch.StartNew();

            int testImgIdx = 8392;

            _lbl = DataManager.Test.Labels[testImgIdx];
            _img = new Texture2D(32, 32, TextureFormat.ARGB32, false, true);
            DataManager.ToTexture(DataManager.Test, testImgIdx, _img);

            Test();
        }
예제 #4
0
        private void Awake()
        {
            Application.runInBackground = true;

            DataManager.LoadFloatData();

            _rng = new Rng(1234);

            var config = new FCNetworkConfig();

            config.Layers.Add(new FCLayerConfig {
                NumNeurons = DataManager.ImgDims
            });
            config.Layers.Add(new FCLayerConfig {
                NumNeurons = 30
            });
            config.Layers.Add(new FCLayerConfig {
                NumNeurons = 10
            });

            _net = new FCNetwork(config);
            NeuralUtils.Initialize(_net, ref _rng);

            _gradients    = new FCGradients(config);
            _gradientsAvg = new FCGradients(config);
            _batch        = new NativeArray <int>(BatchSize, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            _targetOutputs = new NativeArray <float>(OutputClassCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            _dCdO          = new NativeArray <float>(OutputClassCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            _watch = System.Diagnostics.Stopwatch.StartNew();

            // Visual test of data
            const int testImgIdx = 18;

            _label          = DataManager.TrainFloats.Labels[testImgIdx];
            _tex            = new Texture2D(DataManager.Width, DataManager.Height, TextureFormat.ARGB32, false, true);
            _tex.filterMode = FilterMode.Point;
            DataManager.ToTexture(DataManager.TrainFloats, testImgIdx, _tex);

            Test();
        }