예제 #1
0
        private Layer ConvertMean(tflite.Operator op)
        {
            var inputs = op.GetInputsArray();
            var input  = _graph.Tensors(inputs[0]).Value;
            var axes   = _model.GetTensor <int>(_graph.Tensors(inputs[1]).Value);
            var output = _graph.Tensors(op.GetOutputsArray()[0]).Value;

            if (axes.ToArray().SequenceEqual(new[] { 1, 2 }))
            {
                var layer = new GlobalAveragePool(input.GetShapeArray().ToNCHW());
                _inputs.Add(layer.Input, inputs[0]);
                var reshape = new Reshape(layer.Output.Dimensions, output.GetShapeArray().ToNCHW());
                reshape.Input.SetConnection(layer.Output);
                _outputs.Add(op.Outputs(0), reshape.Output);
                return(reshape);
            }
            else
            {
                throw new LayerNotSupportedException(op.ToString(), "Only [1,2] axis mean is supported");
            }
        }