コード例 #1
0
ファイル: FullyConnectedLayer.cs プロジェクト: phucnv31/RL
        public FullyConnectedLayer(LayerDefinition def) : base()
        {
            // required
            this.out_depth = def.num_neurons;

            // optional
            this.l1_decay_mul = def.l1_decay_mul != double.MinValue ? def.l1_decay_mul : 0.0;
            this.l2_decay_mul = def.l2_decay_mul != double.MinValue ? def.l2_decay_mul : 1.0;

            // computed
            this.num_inputs = def.in_sx * def.in_sy * def.in_depth;
            this.out_sx     = 1;
            this.out_sy     = 1;
            this.type       = "fc";

            // initializations
            var bias = def.bias_pref != double.MinValue ? def.bias_pref : 0.0;

            this.filters = new List <Volume>();
            for (var i = 0; i < this.out_depth; i++)
            {
                this.filters.Add(new Volume(1, 1, this.num_inputs));
            }
            this.biases = new Volume(1, 1, this.out_depth, bias);
        }
コード例 #2
0
ファイル: ConvLayer.cs プロジェクト: phucnv31/RL
        public ConvLayer(LayerDefinition def) : base()
        {
            // required
            this.out_depth = def.n_filters;
            this.sx        = def.sx; // filter size. Should be odd if possible, it's cleaner.
            this.in_depth  = def.in_depth;
            this.in_sx     = def.in_sx;
            this.in_sy     = def.in_sy;

            // optional
            this.sy           = def.sy != int.MinValue ? def.sy : this.sx;
            this.stride       = def.stride != int.MinValue ? def.stride : 1; // stride at which we apply filters to input volume
            this.pad          = def.pad != int.MinValue ? def.pad : 0;       // amount of 0 padding to add around borders of input volume
            this.l1_decay_mul = def.l1_decay_mul != double.MinValue ? def.l1_decay_mul : 0.0;
            this.l2_decay_mul = def.l2_decay_mul != double.MinValue ? def.l2_decay_mul : 1.0;

            // computed
            // note we are doing floor, so if the strided convolution of the filter doesnt fit into the input
            // volume exactly, the output volume will be trimmed and not contain the (incomplete) computed
            // final application.
            this.out_sx = (int)Math.Floor((double)(def.in_sx + this.pad * 2 - this.sx) / this.stride + 1);
            this.out_sy = (int)Math.Floor((double)(def.in_sy + this.pad * 2 - this.sy) / this.stride + 1);
            this.type   = "conv";

            // initializations
            var bias = def.bias_pref != double.MinValue ? def.bias_pref : 0.0;

            this.filters = new List <Volume>();
            for (var i = 0; i < this.out_depth; i++)
            {
                this.filters.Add(new Volume(this.sx, this.sy, this.in_depth));
            }
            this.biases = new Volume(1, 1, this.out_depth, bias);
        }
コード例 #3
0
 public ReLULayer(LayerDefinition def) : base()
 {
     // computed
     this.out_sx    = def.in_sx;
     this.out_sy    = def.in_sy;
     this.out_depth = def.in_depth;
     this.type      = "relu";
 }
コード例 #4
0
 public SVMLayer(LayerDefinition def) : base()
 {
     // computed
     this.num_inputs = def.in_sx * def.in_sy * def.in_depth;
     this.out_depth  = this.num_inputs;
     this.out_sx     = 1;
     this.out_sy     = 1;
     this.type       = "svm";
 }
コード例 #5
0
ファイル: RegressionLayer.cs プロジェクト: phucnv31/RL
 public RegressionLayer(LayerDefinition def) : base()
 {
     // computed
     this.num_inputs = def.in_sx * def.in_sy * def.in_depth;
     this.out_depth  = this.num_inputs;
     this.out_sx     = 1;
     this.out_sy     = 1;
     this.type       = "regression";
 }
コード例 #6
0
 public DropoutLayer(LayerDefinition def) : base()
 {
     // computed
     this.out_sx    = def.in_sx;
     this.out_sy    = def.in_sy;
     this.out_depth = def.in_depth;
     this.type      = "dropout";
     this.drop_prob = def.drop_prob != double.NaN ? def.drop_prob : 0.5;
     this.dropped   = new bool[this.out_sx * this.out_sy * this.out_depth];
 }
コード例 #7
0
        public InputLayer(LayerDefinition def) : base()
        {
            // required: depth
            this.out_depth = def.out_depth;

            // optional: default these dimensions to 1
            this.out_sx = def.out_sx;
            this.out_sy = def.out_sy;

            // computed
            this.type = "input";
        }