当前位置:网站首页>Keras 模型多输出 loss weight metrics 设置
Keras 模型多输出 loss weight metrics 设置
2022-08-05 11:34:00 【为为为什么】
keras支持模型多输入多输出,本文记录多输出时loss、loss weight和metrics的设置方式。
模型输出
假设模型具有多个输出
- classify: 二维数组,分类softmax输出,需要配置交叉熵损失
- segmentation:与输入同尺寸map,sigmoid输出,需要配置二分类损失
- others:自定义其他输出,需要自定义损失
具体配置
model
- 变量均为模型中网络层
inputs = [input_1 , input_2]
outputs = [classify, segmentation, others]
model = keras.models.Model(inputs, outputs)loss
my_loss = {
'classify': 'categorical_crossentropy',\
'segmentation':'binary_crossentropy',\
'others':my_loss_fun}loss weight
my_loss_weights = {
'classify':1,\
'segmentation':1,\
'others':10}metrics
my_metrics ={
'classify':'acc',\
'segmentation':[mean_iou,'acc'],\
'others':['mse','acc']
}编译
model.compile(optimizer=Adam(lr=config.LEARNING_RATE), loss=my_loss, loss_weights= my_loss_weights, metrics= my_metrics)边栏推荐
- .NET深入解析LINQ框架(六:LINQ执行表达式)
- The fuse: OAuth 2.0 four authorized login methods must read
- Http-Sumggling Cache Vulnerability Analysis
- UDP通信
- 如何用Golang来手写一个Blog - Milu.blog 开发总结
- Go学习笔记(篇二)初识Go
- 知乎提问:中国是否还能实现伟大民族复兴
- 平安萌娃卡保险怎么样?让父母读懂几个识别产品的方法
- How to write a blog with Golang - Milu.blog development summary
- OpenHarmony如何查询设备类型
猜你喜欢
随机推荐
时间格式2020-01-13T16:00:00.000Z中的T和Z分别表示什么,如何处理
“小钢炮”气质明显,安全、舒适一个不落
Apache APISIX Ingress v1.5-rc1 发布
Go编译原理系列9(函数内联)
Introduction to the Evolution of Data Governance System
Naive bayes
金融业“限薪令”出台/ 软银出售过半阿里持仓/ DeepMind新实验室成立... 今日更多新鲜事在此...
Http-Sumggling Cache Vulnerability Analysis
“蘑菇书”是怎样磨出来的?
自定义过滤器和拦截器实现ThreadLocal线程封闭
hdu1455 Sticks(搜索+剪枝+剪枝+.....+剪枝)
【加密解密】明文加密解密-已实现【已应用】
PostgreSQL 2022 Report: Rising popularity, open source, reliability and scaling key
What do T and Z in the time format 2020-01-13T16:00:00.000Z represent and how to deal with them
I'm going crazy.Again A few days can not be A problem
hdu4545 Magic String
深度学习(四)分析问题与调参 理论部分
shell编程流程控制练习
Image segmentation model - a combination of segmentation_models_pytorch and albumations to achieve multi-category segmentation
Android 开发用 Kotlin 编程语言一 基本数据类型









