TorchSharp icon indicating copy to clipboard operation
TorchSharp copied to clipboard

Having trouble accessing training property of module

Open asieradzk opened this issue 11 months ago • 2 comments

I tried to implement my own module and when attempting to read training property I get access violation error

from torchsharp

public virtual bool training
{
    get
    {
        bool result = NativeMethods.THSNN_Module_is_training(handle);
        CheckForErrors();
        return result;
    }
}

From my module:

        public override Tensor forward(Tensor input)
        {    
            Tensor weight = training ? _weightMu + _weightSigma * _weightEpsilon : _weightMu;
            Tensor bias = _biasMu is not null ? (training ? _biasMu + _biasSigma * _biasEpsilon : _biasMu) : null;
            return torch.nn.functional.linear(input, weight, bias);
        }
        
     
    I wanted to inherit linear but someone made it sealed for some reason but thats another issue. 

asieradzk avatar Mar 12 '24 12:03 asieradzk

failed to reproduce?

image

yueyinqiu avatar Mar 15 '24 12:03 yueyinqiu