Giter VIP home page Giter VIP logo

Comments (3)

Hzzone avatar Hzzone commented on July 18, 2024 1
import torch
from torch import nn
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.w = torch.rand(2, 2)
        self.w.requires_grad = True

    def forward(self, x):
        return self.w*x
net = Net()
net(torch.rand(2, 2))
tensor([[0.0726, 0.2216],
        [0.3548, 0.8168]], grad_fn=<MulBackward0>)
list(net.parameters())
[]
net.w.requires_grad
True
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.w = nn.Parameter(torch.rand(2, 2))

    def forward(self, x):
        return self.w*x
net = Net()
list(net.parameters())
[Parameter containing:
 tensor([[0.8596, 0.7057],
         [0.6475, 0.5657]], requires_grad=True)]

from convolutional_lstm_pytorch.

Hzzone avatar Hzzone commented on July 18, 2024

You are right, plz refer to convLSTM.py#L14 which states the reason.

from convolutional_lstm_pytorch.

bkoyuncu avatar bkoyuncu commented on July 18, 2024

Thank you for your comment. I am new to pytorch and your explanation is not very clear for me, can you elaborate on that? To my knowledge nn.Parameters are included in model.parameters() so that they are updated with each call of optimizer.step() (what do you mean by forever?) I suppose that Wci,Wcf,Wco also should be trainable in the network.

Paper for convlstm : https://arxiv.org/abs/1506.04214
and your explaination,

-if using requires_grad flag, torch.save will not save parameters in deed although it may be updated every epoch.
-Howerver, if you use declare an optimizer like Adam(model.parameters()),
-parameters will not be updated forever.

Thank you

from convolutional_lstm_pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.