Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble accessing training property of module #1267

Open
asieradzk opened this issue Mar 12, 2024 · 2 comments
Open

Having trouble accessing training property of module #1267

asieradzk opened this issue Mar 12, 2024 · 2 comments

Comments

@asieradzk
Copy link

asieradzk commented Mar 12, 2024

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. 
@yueyinqiu
Copy link
Contributor

failed to reproduce?

image

@NiklasGustafsson
Copy link
Contributor

@asieradzk The access violation would suggest that the 'handle' field is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants