Git Product home page Git Product logo

Comments (2)

tastelikefeet avatar tastelikefeet commented on August 17, 2024

你好,loss是由模型的forward方法返回的,也就是说由模型负责计算,您可以对模型进行继承或定制,不需要定制trainer。
具体的方法:

  1. 查看被训练模型中,loss function的定义,继承该模型并覆盖掉loss function
  2. 新的模型上加上注解,模型类型自定义一个
  3. 在trainer的cfg_modify_fn中,将cfg的model.type字段改为新的模型类型

代码看起来就像这样:
`
@MODELS.register_model('old-task-name', 'new-model-name')
class NewModel(ToBeTrainedModel):
def init(...):
# may be change the loss function here
...
def forward(...):
# may be change the loss function here
...

def cfg_modify_fn(cfg):
cfg.model.type = 'new-model-name'
# other changes here
...

trainer = build_trainer('trainer', model='some-model-dir-or-id', cfg_modify_fn=cfg_modify_fn, **other_kwargs)
trainer.train()
`

from modelscope.

yingdachen avatar yingdachen commented on August 17, 2024

close as "resolved"

from modelscope.

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.