Exemple #1
0
        public IMatrix ExecuteToMatrix(I3DTensor tensor)
        {
            IMatrix input;

            if (_padding > 0)
            {
                using (var padded = tensor.AddPadding(_padding))
                    input = padded.Im2Col(_filterWidth, _filterHeight, _stride);
            }
            else
            {
                input = tensor.Im2Col(_filterWidth, _filterHeight, _stride);
            }

            // execute the layer
            var ret = _layer.Activate(input);

            input.Dispose();
            return(ret);
        }
Exemple #2
0
        IMatrix _Execute(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation)
        {
            var     layer = _trainer.LayerUpdater.Layer;
            IMatrix input;

            if (_descriptor.Padding > 0)
            {
                using (var padded = tensor.AddPadding(_descriptor.Padding))
                    input = padded.Im2Col(_descriptor.FilterWidth, _descriptor.FilterHeight, _descriptor.Stride);
            }
            else
            {
                input = tensor.Im2Col(_descriptor.FilterWidth, _descriptor.FilterHeight, _descriptor.Stride);
            }

            var output = layer.Execute(input);

            if (backpropagation != null)
            {
                backpropagation?.Push(new Backpropagation(this, _trainer, input, output));
                return(layer.Activation?.Calculate(output) ?? output);
            }
            else
            {
                input.Dispose();
                if (layer.Activation == null)
                {
                    return(output);
                }
                else
                {
                    var ret = layer.Activation.Calculate(output);
                    output.Dispose();
                    return(ret);
                }
            }
        }
Exemple #3
0
 public Tensor3DGraphData(I3DTensor tensor) : this(tensor.ReshapeAsMatrix(), tensor.RowCount,
                                                   tensor.ColumnCount)
 {
 }
Exemple #4
0
 public IVector ExecuteToVector(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation)
 {
     using (var ret = ExecuteToTensor(tensor, backpropagation))
         return(ret.ConvertToVector());
 }
Exemple #5
0
 public Tensor3DGraphData(I3DTensor tensor) :
     this(tensor.ConvertToMatrix(), tensor.RowCount, tensor.ColumnCount)
 {
 }
Exemple #6
0
 /// <summary>
 /// Converts the 3D tensor to a generic IGraphData
 /// </summary>
 /// <param name="tensor">Tensor to convert</param>
 public static IGraphData AsGraphData(this I3DTensor tensor)
 {
     return(new Tensor3DGraphData(tensor));
 }
Exemple #7
0
        public IVector ExecuteToVector(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation)
        {
            var outputMatrix = _Execute(tensor, backpropagation);

            return(outputMatrix.ConvertInPlaceToVector());
        }
Exemple #8
0
 public I3DTensor ExecuteToTensor(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation)
 {
     using (var outputMatrix = _Execute(tensor, backpropagation))
         return(ConvertToTensor(outputMatrix));
 }
Exemple #9
0
 public I3DTensor ExecuteToTensor(I3DTensor tensor)
 {
     return(tensor.MaxPool(_filterWidth, _filterHeight, _stride, null));
 }
Exemple #10
0
 public IVector ExecuteToVector(I3DTensor tensor)
 {
     using (var ret = tensor.MaxPool(_filterWidth, _filterHeight, _stride, null))
         return(ret.ConvertToVector());
 }
Exemple #11
0
        public IVector ExecuteToVector(I3DTensor tensor)
        {
            var ret = ExecuteToMatrix(tensor);

            return(ret.ConvertInPlaceToVector());
        }