当前位置:网站首页>Tensorflow2.0 混淆矩阵与打印准确率不符
Tensorflow2.0 混淆矩阵与打印准确率不符
2022-07-30 18:59:00 【赫凯】
最近在做一个二分类的项目,模型最后几层是这样的,最后用了sigmiod激活。
model.add(tf.keras.layers.Dense(64, activation='relu'))
model.add(tf.keras.layers.Dropout(0.5)),
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
损失函数用了这个
tf.keras.losses.binary_crossentropy
跑起来就是
model.fit(
...
)
打印的信息效果还不错,最后我又用混淆矩阵看了一眼,吐了,完全不对,调了一整天,最后终于发现,预测出来的是概率。这么写,用y_pred 就OK啦。
pred = self.model.predict(x)
y_pred = (pred>0.5).astype(int)
边栏推荐
猜你喜欢

CCNA-NAT协议(理论与实验练习)

CCNA-子网划分(VLSM)

NC | 西湖大学陶亮组-TMPRSS2“助攻”病毒感染并介导索氏梭菌出血毒素的宿主入侵...

Fixed asset visualization intelligent management system

Critical Reviews | 南农邹建文组综述全球农田土壤抗生素与耐药基因分布

Codeblocks + Widgets 创建窗口代码分析

自然语言处理nltk

【每日一道LeetCode】——191. 位1的个数

Swiper轮播图片并播放背景音乐

CIMC Shilian Dafeitong is the global industrial artificial intelligence AI leader, the world's top AI core technology, high generalization, high robustness, sparse sample continuous learning, industri
随机推荐
【每日一道LeetCode】——191. 位1的个数
kotlin by lazy
Range.CopyFromRecordset 方法 (Excel)
微信小程序云开发 | 城市信息管理
Spark学习:编译Spark项目时遇到的报错
Pytorch foundation -- tensorboard use (1)
The use of @ symbol in MySql
- daily a LeetCode 】 【 191. A number of 1
【Prometheus】Prometheus联邦的一次优化记录[续]
What kind of framework is friendly to developers?
还有三天忙完
LeetCode每日一题(1717. Maximum Score From Removing Substrings)
谷歌AlphaFold近日宣称预测出地球上几乎所有蛋白质结构
Graphic LeetCode -- 11. Containers of most water (difficulty: medium)
Chapter 14 Type Information
在华为云,见证迷你世界的神奇觉醒
AWS 控制台
怎么样的框架对于开发者是友好的?
JsonUtil基于字符串操作josn
Multiple instances of mysql