Comments (2)
你好,loss是由模型的forward方法返回的,也就是说由模型负责计算,您可以对模型进行继承或定制,不需要定制trainer。
具体的方法:
- 查看被训练模型中,loss function的定义,继承该模型并覆盖掉loss function
- 新的模型上加上注解,模型类型自定义一个
- 在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.
close as "resolved"
from modelscope.
Related Issues (20)
- iic/cv_resnet_carddetection_scrfd34gkps如何导出 onnx HOT 1
- 纠错模型批量推理错误 HOT 2
- StructBERT问句识别-中文口语-通用领域项目BUG HOT 2
- “ClassDef”对象没有属性“type_params” HOT 7
- modelscope guide help HOT 2
- need offline support HOT 7
- 数据集中有数据被误封了,见desc中的截图,请求帮忙解封 HOT 2
- 数据集中有数据被误封了,见#925,请求帮忙解封。注意不是恢复数据,是解封数据中某个音频 HOT 3
- TypeError: PreTrainedTokenizerFast._batch_encode_plus() got an unexpected keyword argument 'label2id' HOT 1
- Pip install modelscope==1.16.1未能完全安装依赖项,ModuleNotFoundError: No module named 'addict' HOT 2
- Converting safetensors to modelscope format HOT 1
- 时间轴有问题 HOT 4
- 如何屏蔽 - modelscope - INFO - 和 WARNING 级别的log打印 HOT 2
- vllm load model from modelscope: re.error: multiple repeat at position 10
- in facechain rp HOT 1
- md中的<a href="#id"> 或者(id)[#id] 在平台上会被重置成file/view 导致其正常跳转至readme某章节失效 HOT 6
- 'scrfd is not in the exporters registry group face-detection HOT 1
- 打扰问下目前是不是还没法解散组织 HOT 7
- static静态网页类型的创空间,若有页面跳转会报跨域封锁 HOT 2
- 无cookie记录的浏览器首次进入组织链接 https://www.modelscope.cn/organization/xxx 时会报403无访问权限 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modelscope.