Git Product home page Git Product logo

Comments (4)

dsp6414 avatar dsp6414 commented on May 15, 2024

models/backbone/resnet.py

from yolodet-pytorch.

wuzhihao7788 avatar wuzhihao7788 commented on May 15, 2024

感觉这位置应该为True,是我理解错了吗?
还有如果目标类别和预训练模型不一样可以加载预训练模型吗?

具体那个位置?resnet在配置文件里有定义。冻结那几几层的残差块

from yolodet-pytorch.

dsp6414 avatar dsp6414 commented on May 15, 2024

def _freeze_stages(self):
if self.frozen_stages >= 0:
self.norm1.eval()
for m in [self.conv1, self.norm1]:
for param in m.parameters():
param.requires_grad = False #我觉得这里是不是应该为True

    for i in range(1, self.frozen_stages + 1):
        m = getattr(self, 'layer{}'.format(i))
        m.eval()
        for param in m.parameters():
            param.requires_grad = False

from yolodet-pytorch.

wuzhihao7788 avatar wuzhihao7788 commented on May 15, 2024

def _freeze_stages(self):
if self.frozen_stages >= 0:
self.norm1.eval()
for m in [self.conv1, self.norm1]:
for param in m.parameters():
param.requires_grad = False #我觉得这里是不是应该为True

    for i in range(1, self.frozen_stages + 1):
        m = getattr(self, 'layer{}'.format(i))
        m.eval()
        for param in m.parameters():
            param.requires_grad = False

这部分代码没有问题,frozen_stages 默认值为-1, param.requires_grad = False,在反向梯度更新的时候叶子节点不更新权重,网络层冻结。 param.requires_grad = True是默认值,默认所有的叶子节点都更新梯度。

from yolodet-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.