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); }
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); } } }
public Tensor3DGraphData(I3DTensor tensor) : this(tensor.ReshapeAsMatrix(), tensor.RowCount, tensor.ColumnCount) { }
public IVector ExecuteToVector(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation) { using (var ret = ExecuteToTensor(tensor, backpropagation)) return(ret.ConvertToVector()); }
public Tensor3DGraphData(I3DTensor tensor) : this(tensor.ConvertToMatrix(), tensor.RowCount, tensor.ColumnCount) { }
/// <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)); }
public IVector ExecuteToVector(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation) { var outputMatrix = _Execute(tensor, backpropagation); return(outputMatrix.ConvertInPlaceToVector()); }
public I3DTensor ExecuteToTensor(I3DTensor tensor, Stack <IConvolutionalLayerBackpropagation> backpropagation) { using (var outputMatrix = _Execute(tensor, backpropagation)) return(ConvertToTensor(outputMatrix)); }
public I3DTensor ExecuteToTensor(I3DTensor tensor) { return(tensor.MaxPool(_filterWidth, _filterHeight, _stride, null)); }
public IVector ExecuteToVector(I3DTensor tensor) { using (var ret = tensor.MaxPool(_filterWidth, _filterHeight, _stride, null)) return(ret.ConvertToVector()); }
public IVector ExecuteToVector(I3DTensor tensor) { var ret = ExecuteToMatrix(tensor); return(ret.ConvertInPlaceToVector()); }