Exemplo n.º 1
0
        internal static NDArrayOrSymbol[] GetBeginState(RecurrentCell cell, NDArrayOrSymbol[] begin_state,
                                                        NDArrayOrSymbol inputs, int batch_size)
        {
            if (begin_state != null)
            {
                if (inputs.IsNDArray)
                {
                    var ctx  = inputs.NdX.Context;
                    var args = new FuncArgs();
                    args.Add("ctx", ctx);
                    begin_state = cell.BeginState(batch_size, "nd.Zeros", args);
                }
                else
                {
                    begin_state = cell.BeginState(batch_size, "sym.Zeros");
                }
            }

            return(begin_state);
        }
Exemplo n.º 2
0
        public override KerasSymbol[] Invoke(KerasSymbol[] inputs, FuncArgs kwargs = null)
        {
            List <KerasSymbol> result = new List <KerasSymbol>();
            bool training             = kwargs.Get <bool>("training");

            foreach (var input in inputs)
            {
                Func <KerasSymbol> dropped_inputs = () => {
                    return(K.Dropout(input, this.rate, noise_shape, seed: this.seed));
                };

                if ((0 < this.rate) && (this.rate < 1.0))
                {
                    var noise_shape = this.GetNoiseShape(input);
                    result.Add(K.InTrainPhase(dropped_inputs, input, training: training));
                }
            }

            return(result.ToArray());
        }
Exemplo n.º 3
0
        public StateInfo(FuncArgs args)
        {
            foreach (var arg in args)
            {
                if (arg.Value == null)
                {
                    continue;
                }

                switch (arg.Key.ToLower())
                {
                case "shape":
                    Shape = (Shape)arg.Value;
                    break;

                case "layout":
                    Layout = arg.Value.ToString();
                    break;

                case "in_layout":
                    Layout = arg.Value.ToString();
                    break;

                case "mean":
                    Mean = Convert.ToSingle(arg.Value);
                    break;

                case "std":
                    Mean = Convert.ToSingle(arg.Value);
                    break;

                case "dtype":
                    DataType = (DType)arg.Value;
                    break;

                case "ctx":
                    Ctx = (Context)arg.Value;
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public override KerasSymbol[] Invoke(KerasSymbol[] inputs, FuncArgs kwargs = null)
        {
            List <KerasSymbol> result = new List <KerasSymbol>();

            foreach (var input in inputs)
            {
                var output = K.Dot(input, this.kernel);
                if (this.use_bias)
                {
                    output = K.BiasAdd(output, this.bias, data_format: "channels_last");
                }

                result.Add(output);
            }

            if (this.activation != null)
            {
                return(this.activation.Invoke(result.ToArray()));
            }

            return(result.ToArray());
        }
Exemplo n.º 5
0
 public FastSEResNet(string architecture, string norm_layer = "BatchNorm", FuncArgs kwargs = null, string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
        public DarknetV3(int[] layers, int[] channels, int classes = 1000, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = null, ParameterDict @params = null) : base(prefix, @params)
        {
            Debug.Assert(layers.Length == channels.Length - 1, $"len(channels) should equal to len(layers) + 1, given {channels.Length} vs {layers.Length}");
            this.features = new HybridSequential();
            // first 3x3 conv
            this.features.Add(Conv2d(channels[0], 3, 1, 1, norm_layer: norm_layer, norm_kwargs: norm_kwargs));
            for (int i = 0; i < layers.Length; i++)
            {
                int nlayer  = layers[i];
                int channel = channels[i];
                Debug.Assert(channel % 2 == 0, $"channel {channel} cannot be divided by 2");
                // add downsample conv with stride=2
                this.features.Add(Conv2d(channel, 3, 1, 2, norm_layer: norm_layer, norm_kwargs: norm_kwargs));
                // add nlayer basic blocks
                foreach (var _ in Enumerable.Range(0, nlayer))
                {
                    this.features.Add(new DarknetBasicBlockV3(channel / 2, norm_layer: norm_layer, norm_kwargs: norm_kwargs));
                }
            }

            // output
            this.output = new Dense(classes);

            RegisterChild(features);
            RegisterChild(output);
        }
Exemplo n.º 7
0
 public IDAUp(int out_channels, int in_channels, float[] up_f, bool use_dcnv2 = false, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 private HybridSequential MakeBasicConv(int in_channels, int channels, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
        public override NDArrayOrSymbol[] BeginState(int batch_size = 0, string func = null, FuncArgs args = null)
        {
            BaseCell._modified = false;
            var begin = BaseCell.BeginState(batch_size, func, args);

            BaseCell._modified = true;
            return(begin);
        }
Exemplo n.º 10
0
 public static CIFARResNetV2 Cifar_ResNet110_V2(bool pretrained = false, Context ctx = null, string root = "~/mxnet", string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 11
0
 public static HybridSequential MakeLayerSlow(int inplanes, int planes, int num_blocks, int?num_block_temp_kernel_slow = null, string block = "Bottleneck",
                                              int strides = 1, int head_conv = 1, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string layer_name = "")
 {
     throw new NotImplementedException();
 }
Exemplo n.º 12
0
 public NASNetALarge(int repeat        = 6, int penultimate_filters = 4032, int stem_filters     = 96, int filters_multiplier = 2, int classes = 1000, bool use_aux = true,
                     string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = "", ParameterDict @params  = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
 public ResidualBlock(int channels, int?in_channels = null, int stride = 1, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = null, ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
 public BasicBlock(int inplanes, int planes, int spatial_stride = 1, int temporal_stride = 1, int dilation = 1, bool downsample = false, bool if_inflate = true, string inflate_style = "", string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string layer_name = "", string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 15
0
 public Bottleneck(int inplanes, int planes, int spatial_stride = 1, int temporal_stride = 1, int dilation = 1, bool downsample = false, bool if_inflate = true, string inflate_style = "3x1x1", string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string layer_name = "", string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
 }
Exemplo n.º 16
0
 public CIFARResNetV2(HybridBlock block, int[] layers, int[] channels, int classes = 10, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 private HybridSequential MakeLayer(HybridBlock block, int[] layers, int[] channels, int stride, int stage_index, int in_channels = 0, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 18
0
 public Bottleneck(int inplanes, int planes, int strides = 1, bool downsample = false, int head_conv = 1, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null,
                   string layer_name = "", string prefix = null, ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
 public Tree(int levels, HybridBlock block, int in_channels, int out_channels, int stride = 1, bool level_root = false, int root_dim = 0, int root_kernel_size = 1,
             int dilation = 1, bool root_residual = false, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = null, ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 public SE_BasicBlockV2(int channels, int stride, bool downsample = false, int in_channels = 0, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
 }
Exemplo n.º 21
0
 public GoogLeNet(int classes = 1000, string norm_layer = "BatchNorm", float dropout_ratio = 0.4f, bool aux_logits = false, FuncArgs norm_kwargs = null, bool partial_bn = false, bool pretrained_base = true, Context ctx = null, string prefix = null, ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
 public override KerasSymbol[] Invoke(KerasSymbol[] inputs, FuncArgs kwargs = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 23
0
 private HybridSequential MakeBranch(bool use_pool, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, int?channels = null, (int, int)?kernel_size = null, (int, int)?strides = null, (int, int)?padding = null)
Exemplo n.º 24
0
 public NormalCell(int out_channels_left, int out_channels_right, string norm_layer, FuncArgs norm_kwargs, string prefix = null, ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 25
0
 public MaskRCNN(HybridBlock features, HybridBlock top_features, string[] classes, int mask_channels = 256, int rcnn_max_dets = 1000, int rpn_test_pre_nms = 6000, int rpn_test_post_nms = 1000, int target_roi_scale = 1, int num_fcn_convs = 0, string norm_layer = "", FuncArgs norm_kwargs = null, string prefix = null, ParameterDict @params = null) : base(features: features, top_features: top_features, classes: classes, rpn_test_pre_nms: rpn_test_pre_nms, rpn_test_post_nms: rpn_test_post_nms, additional_output: true, prefix: prefix, @params: @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 26
0
 private HybridSequential ASPPConv(int in_channels, int out_channels, float atrous_rate, string norm_layer, FuncArgs norm_kwargs)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
        internal static HybridSequential Conv2d(int channel, int kernel, int padding, int stride, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null)
        {
            var cell = new HybridSequential(prefix: "");

            cell.Add(new Conv2D(channel, kernel_size: (kernel, kernel), strides: (stride, stride), padding: (padding, stride), use_bias: false));
            cell.Add(LayerUtils.NormLayer(norm_layer, norm_kwargs));
            cell.Add(new LeakyReLU(0.1f));
            return(cell);
        }
Exemplo n.º 28
0
 public _DeepLabHead(int nclass, int c1_channels = 128, string norm_layer = "BatchNorm", FuncArgs norm_kwargs = null, int height = 240, int width = 240, string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 29
0
 public Node(Layer outbound_layer, Layer[] inbound_layers, int[] node_indices, int[] tensor_indices, KerasSymbol[] input_tensors, KerasSymbol[]  output_tensors, KerasSymbol[] input_masks, KerasSymbol[] output_masks, Shape[] input_shapes, Shape[] output_shapes,
             FuncArgs arguments = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 30
0
 public _ASPP(int in_channels, int out_channels, string norm_layer, FuncArgs norm_kwargs, int height = 60, int width = 60, string prefix = "", ParameterDict @params = null) : base(prefix, @params)
 {
     throw new NotImplementedException();
 }