当前位置: 首页 > news >正文

MySQL 学习笔记(刷题篇)

SQL进阶挑战

聚合分组查询

SQL123

select tag, difficulty, round((sum(score) - max(score) - min(score) ) / (count(score) - 2) ,1)
as clip_avg_score
from examination_info as ei, exam_record as er
where ei.exam_id = er.exam_id  
and ei.tag = 'SQL'  
and ei.difficulty = 'hard' 
and er.score is not null;

SQL124

IF(expr1 , expr2 , expr3),expr1的值为TRUE 返回 expr2,否则返回 expr3
使用 distinct 是需要考虑 null 的,它会把 null 也算成一种情况
但是使用 count(字段) 是不用考虑 null 的,它不会计 null 为一种情况

select count(id) as total_pv, 
count(submit_time) as complete_pv, 
count(distinct if(submit_time is not null, exam_id, null)) as complete_exam_cnt
from exam_record
select count(id) as total_pv, 
count(submit_time) as complete_pv, 
count(distinct exam_id and score is not null) as complete_exam_cnt
from exam_record

SQL125

# 这样写为什么就错?
select min(score) as min_score_over_avg
from exam_record  #这样写没有保证查询的试卷类型是SQL
where score >= (select avg(score)from exam_record as er , examination_info as eiwhere ei.tag = 'SQL'and ei.exam_id = er.exam_idand er.score is not null
);
# correct
select min(score) as min_score_over_avg
from exam_record as er , examination_info as ei
where ei.tag = 'SQL'
and ei.exam_id = er.exam_id
and er.score is not null
and score >= (select avg(score)from exam_record as erwhere er.exam_id = ei.exam_idand er.score is not null
);

SQL126

题目:按年月进行分组,统计每组的用户id个数(也就是这个月有多少活跃用户),统计每组的用户活跃天数的平均值(总天数/总人数)
总天数计算方法: ∑ i = 1 i = l a s t − u s e r 第 i 个用户一个月内的登录天数之和 \sum_{i=1}^{i=last-user} 第i个用户一个月内的登录天数之和 i=1i=lastuseri个用户一个月内的登录天数之和

DATE_FORMAT(date,fmt) 按照字符串 fmt 格式化日期 date
YEAR(date) / MONTH(date) / DAY(date) 返回具体的日期值

count( distinct uid, date_format(submit_time, '%y%m%d') ),这里的知识点:count函数内本只能接收一个参数,distinct 修饰是所有字段的,并不是修饰一个字段
语句含义:去掉一个用户在一天内的多次登录计数的重复计数,保证如果同一用户在同一天进行了多次活动,只有一次会被计数。

select date_format(submit_time, '%Y%m') as month, # %Y四位年份,%m两位数字月份round( count(distinct uid, date_format(submit_time, '%y%m%d') )  / count(distinct uid) , 2) as avg_active_days,count(distinct uid) as mau #统计组内不同用户id数量
from exam_record
where submit_time is not null
and year(submit_time) = 2021
group by date_format(submit_time, '%Y%m') # 按照年月分组

SQL127

select date_format(submit_time, '%Y%m') as submit_month,count(distinct uid, submit_time) as month_q_cnt,round(count(distinct uid, submit_time) / max(DAY(LAST_DAY(submit_time))) #这里必须用一个聚合函数,由于汇总时的天数按31算,因此用max最为合适,day+lasy_day一起得到当月的天数, 3) as avg_day_q_cnt
from practice_record
where year(submit_time) = '2021' #过滤字段写到分组前
group by submit_monthunionselect '2021汇总' as submit_month,
count(distinct uid, submit_time) as month_q_cnt,
round(count(distinct uid, submit_time) / 31, 3) as avg_day_q_cnt
from practice_record
where year(submit_time) = '2021'order by submit_month;

COALESCE 是一个函数,coalesce (expression_1, expression_2, …,expression_n) ,依次检验,返回第一个不是 null 的值

MySQL5.7之后,sql_mode中ONLY_FULL_GROUP_BY模式默认设置为打开状态。
ONLY_FULL_GROUP_BY的语义就是确定select target list中的所有列的值都是明确语义,因此这里的coalesce是不好使的,可以通过any_value()函数来抑制ONLY_FULL_GROUP_BY值被拒绝,any_value()会选择被分到同一组的数据里第一条数据的指定列值作为返回数据

GROUP BY中使用WITH ROLLUP
WITH ROLLUP,使用 WITH ROLLUP 关键字之后,在所有查询出的分组记录之后增加一条记录,该记录计算查询出的所有记录的总和
注意:当使用ROLLUP时,不能同时使用ORDER BY子句进行结果排序,即ROLLUP和ORDER BY是互相排斥的。

SELECTany_value(coalesce(DATE_FORMAT(submit_time,"%Y%m"),'2021汇总')) as submit_month,count(submit_time) as month_q_cnt,# 因为汇总除的数也是31,因此这里取max聚合round(count(submit_time) / max(day(last_day(submit_time))),3) as avg_day_q_cnt
FROM practice_record
WHERE year(submit_time) = '2021'
GROUP BY date_format(submit_time,"%Y%m") with rollup;

SQL 128

使用 count() 函数实现条件统计的基础是:对于值为NULL的记录不计数,利用这个性质我们可以轻松统计出值不为 NULL 的记录,再统计总记录,即可得到值为 NULL 的记录。

# 统计num大于200的记录
select count(num > 200 or null) from a;
# or null 作用就是当条件不满足时,函数变成了count(null)不会统计数量
# 但是 num > 200 这个条件不成立时的 false 是会被统计到的

GROUP_CONCAT() 函数是mysql中非常实用的聚合函数,将给分组内的值连接为一个字符串。其完整语法:

GROUP_CONCAT([DISTINCT] 要连接的字段 [ORDER BY 排序字段 ASC/DESC] [SEPARATOR ‘分隔符’])
select uid,count(uid) - count(submit_time) as incomplete_cnt,count(submit_time) as complete_cnt,group_concat(distinct date_format(start_time, '%Y-%m-%d'), ':', tagOrder BY start_time ASC #排序字段SEPARATOR ';') as detail
from exam_record as er
inner join examination_info as ei
on er.exam_id = ei.exam_id
where year(start_time) = '2021'  #过滤字段写到分组前
group by uid
having incomplete_cnt < 5 and incomplete_cnt > 1
and complete_cnt >= 1
order by incomplete_cnt desc;

多表查询

SQL 129

先考虑简单的,找出 “当月均完成试卷数”不小于3的用户们,然后按 tag 分组统计存在 start_time 的作答记录个数即可

select tag, count(start_time) as tag_cnt
from examination_info as ei
inner join exam_record as er
on ei.exam_id = er.exam_id
where uid in (select uidfrom exam_record as erinner join examination_info as eion er.exam_id = ei.exam_idgroup by uid, date_format(start_time, '%Y%m')having count(date_format(submit_time, '%Y%m')) >= 3
)
group by tag
order by tag_cnt desc;

SQL 130

select ei.exam_id as exam_id,count(distinct uid) as uv,# round(avg(score) ,1) as avg_scoreround(sum(score) / count(score) , 1) as avg_score
from examination_info as ei
inner join exam_record as er
on ei.exam_id = er.exam_id
where date_format(start_time, '%Y%m%d') in ( # 时间select date_format(release_time, '%Y%m%d') # 先弄出SQL试卷的发出的时间字段from examination_infowhere tag = 'SQL'
)
and uid in ( # 用户select uid      # 再弄出等级大于5的用户的uidfrom user_infowhere level > 5
)
and tag = 'SQL'  # SQL试卷
group by ei.exam_id #所有的SQL试卷按exam_id分组
order by uv desc, avg_score;

SQL 131

select level, count(level) as level_cnt
from user_info as ui, (select uidfrom exam_record as erinner join examination_info as eion er.exam_id = ei.exam_idwhere tag = 'SQL' && score > 80
) as tmp
where ui.uid = tmp.uid
group by level
order by level_cnt desc;

SQL 132

再套一个 select 来使得子查询的排序独立

select * from (
select exam_id as tid, count(distinct uid) as uv,count(start_time) as pv 
from exam_record
group by exam_id
order by uv desc, pv desc
) as t1unionselect * from (
select question_id as tid,count(distinct uid) as uv,count(submit_time) as pv
from practice_record
group by question_id
order by uv desc, pv desc
) as t2

SQL 133

TIME_TO_SEC() 将时间差转换为秒

select uid, 'activity1' as activity
from exam_record
group by uid
having min(score) >= 85unionselect uid, 'activity2' as activity
from examination_info as ei
inner join exam_record as er
on er.exam_id = ei.exam_id
where score > 80
and difficulty = 'hard'
and TIME_TO_SEC(timediff(submit_time, start_time)) < duration * 30order by uid;

其他操作

SQL 146

select uid,floor(avg(any_value(coalesce(score, 0)))) as avg_score,round(avg(if(submit_time is not null, timestampdiff(minute, start_time, submit_time), duration)), 1) as avg_time_took
from examination_info as ei
inner join exam_record as er
on ei.exam_id = er.exam_id
where difficulty = 'hard'
and uid in (select uidfrom user_infowhere level = 0
)
group by uid

SQL 147

select uid, nick_name, achievement
from user_info
where nick_name like '牛客%'
and nick_name like '%号'
and achievement between 1200 and 2500
and uid in (select uidfrom exam_recordgroup by uidhaving max(date_format(start_time, '%Y%m')) = '202109'union select uidfrom practice_recordgroup by uidhaving max(date_format(submit_time, '%Y%m')) = '202109'
)
select uid, nick_name, achievement
from user_info
where nick_name like '牛客%'
and nick_name like '%号'
and achievement between 1200 and 2500
and (uid in(select uidfrom exam_recordgroup by uidhaving max(date_format(start_time, '%Y%m')) = '202109')or uid in(select uidfrom practice_recordgroup by uidhaving max(date_format(submit_time, '%Y%m')) = '202109')
)

SQL 148(正则表达式)

正则表达式匹配纯数字或者中间纯数字

select uid, er.exam_id,round(avg(score) ,0) as avg_score
from examination_info as ei
inner join exam_record as er
on ei.exam_id = er.exam_id
where uid in (select uidfrom user_infowhere nick_name regexp '^牛客[0-9]+号$'or nick_name regexp '^[0-9]+$'
)
and ei.exam_id in (select exam_idfrom examination_infowhere tag regexp '^[Cc]'
)
and score is not null
group by uid, exam_id
order by uid, avg_score

SQL 149(WITH AS)

比较复杂的一个题,需要用 WITH AS 存一下查询

with t as (select ui.uid as uid,count(start_time) - count(submit_time) as incomplete_cnt,round(if(count(start_time) - count(submit_time) > 0,(count(start_time) - count(submit_time)) / count(start_time),0),3) as incomplete_rate,level,count(start_time) as total_cnt # 作答个数from user_info as uileft join exam_record as eron ui.uid = er.uidgroup by uid
)select uid, incomplete_cnt, incomplete_rate
from t
where exists(select uid from t where level = 0 and incomplete_cnt > 2
)
and level = 0
union
select uid, incomplete_cnt, incomplete_rate
from t
where not exists (select uid from t where level = 0 and incomplete_cnt > 2
)
and total_cnt > 0 # 有作答记录的用户
order by incomplete_rate

SQL150(CASE WHEN THEN)

很烂但有用的代码

select ui.level,case when score >= 90 then '优'when score >= 75 then '良'when score >= 60 then '中'when score >= 0 then '差' end as score_grade,round(count( case when score >= 90 then '优'when score >= 75 then '良'when score >= 60 then '中'when score >= 0 then '差' end) / num, 3) as ratio
from exam_record as er, user_info as ui, (select level, count(level) as numfrom exam_record as erinner join user_info as uion er.uid = ui.uidwhere score is not nullgroup by levelorder by level desc
) as tmp
where er.uid = ui.uid
and tmp.level = ui.level
and score is not null
group by level, score_grade
order by level desc, ratio desc

SQL 152

select er.uid, level, register_time, score as max_score
from exam_record as er
inner join user_info as ui
on er.uid = ui.uid
where exam_id in ( # 把exam_record筛的只剩下job为算法的人做的算法试卷记录select exam_idfrom examination_infowhere tag = '算法'
)
and er.uid in (select uidfrom user_infowhere job = '算法'
)
and score is not null # 还得做完
order by score desc
limit 6, 3;

SQL 153(substring_index)

substring_index(str,delim,count),str:要处理的字符串,delm:分隔符

SELECT exam_id,substring_index(tag, ',', 1) AS tag,substring_index(substring_index(tag, ',', 2), ',', -1) AS difficulty,substring_index(tag, ',', -1) AS duration
FROM examination_info
WHERE tag LIKE '%,%';

SQL 154(IF)

简单的 IF 应用

select uid, (if(char_length(nick_name) > 13, concat(substring(nick_name, 1, 10), '...'),nick_name)
) as nick_name
from user_info
where char_length(nick_name) > 10;

SQL 155

这个题写的我脑子有点乱

select t1.tag, t2.total_num
from (select tag, num # 查询试卷作答数小于3的exam_id对应的tag和个数from examination_info as ei, ( select exam_id, count(exam_id) as num #按exam_id分组,并统计个数from exam_recordgroup by exam_id) as tmpwhere ei.exam_id = tmp.exam_id # 多表查询and num < 3
) as t1, (select tag, sum(num) as total_num #按tag分类,把大写的tag聚合起来统计个数from examination_info as ei, (select exam_id, count(exam_id) as numfrom exam_recordgroup by exam_id) as tmpwhere ei.exam_id = tmp.exam_idgroup by tag 
) as t2
where upper(t1.tag) = t2.tag  # 小写的t1.tag匹配大写的t2.tag
and t1.tag != t2.tag

相关文章:

MySQL 学习笔记(刷题篇)

SQL进阶挑战 聚合分组查询 SQL123 select tag, difficulty, round((sum(score) - max(score) - min(score) ) / (count(score) - 2) ,1) as clip_avg_score from examination_info as ei, exam_record as er where ei.exam_id er.exam_id and ei.tag SQL and ei.diffi…...

windows系统如何配置yarn环境变量

启动前端项目&#xff0c;突然遇到报错&#xff1a; 原因在于没有安装yarn&#xff0c;或没有配置环境变量。 全局安装 yarn 可在vsCode中输入&#xff0c;也可在命令行输入&#xff08;winR&#xff0c;输入cmd&#xff09; npm install -g yarn添加环境变量 找到yarn的安…...

视频中的文字水印怎么去除?这三招学会轻松去视频水印

短视频与我们生活&#xff0c;工作息息相关&#xff0c;日常在在刷短视频时&#xff0c;下载保存后发现带有文字logo水印&#xff0c;如果直接拿来进行二次创作&#xff0c;不仅影响观看效果&#xff0c;平台流量还会受限制。怎么去除视频中的文字水印就成为了当下热门话题之一…...

Java项目学生管理系统二查询所有

学生管理 近年来&#xff0c;Java作为一门广泛应用于后端开发的编程语言&#xff0c;具备了广泛的应用领域和丰富的开发资源。在前几天的博客中&#xff0c;我们探讨了如何搭建前后端环境&#xff0c;为接下来的开发工作打下了坚实的基础。今天&#xff0c;我们将进一步扩展我…...

27.Spring如何避免在并发下获取不完整的Bean?

Spring如何避免在并发下获取不完整的Bean? 1、为什么获取不到完整的Bean? 我们知道, 如果spring容器已经加载完了, 那么肯定所有bean都是完整的了, 但如果, spring没有加载完, 在加载的过程中, 构建bean就有可能出现不完整bean的情况 2、如何解决读取到不完整bean的问题. …...

浅析SD-WAN企业组网部署中简化网络运维的关键技术

网络已经成为现代企业不可或缺的基础设施&#xff0c;它为企业提供了连接全球的桥梁。随着全球化和数字化转型的加速推进&#xff0c;企业面临着越来越多的网络挑战和压力。传统的网络组网方式往往无法满足企业规模扩大、分支机构增多、上云服务等需求&#xff0c;导致网络性能…...

【Rust】快速教程——自定义类型、数字转枚举、Cargo运行

前言 超过一定的年龄之后&#xff0c;所谓人生&#xff0c;无非是一个不断丧失的过程而已。宝贵的东西&#xff0c;会像梳子豁了齿一样从手中滑落下去。你所爱的人会一个接着一个&#xff0c;从身旁悄然消逝。——《1Q84》 \;\\\;\\\; 目录 前言自定义类型数字转枚举Cargo.tom…...

python 实现 AIGC 大语言模型中的概率论:生日相同问题的代码场景模拟

对深度学习本质而言&#xff0c;它实际上就是应用复杂的数学模型对输入数据进行建模&#xff0c;最后使用训练好的模型来预测或生成新的数据&#xff0c;因此深度学习的技术本质其实就是数学。随着大语言模型的发展&#xff0c;人工智能的数学本质被进一步封装&#xff0c;从业…...

SD-WAN组网中的CPE及云服务CPE部署方法

什么是CPE&#xff1f; CPE全称为Customer Premises Equipment&#xff0c;即客户端设备&#xff0c;在SD-WAN中通常为路由器&#xff0c;部署在中心点和分支上&#xff0c;提供连接和路由、协议转换、流量监控等功能。一般可分为硬件CPE和虚拟化CPE&#xff08;virtual CPE&a…...

理解BatchNormalization层的作用

深度学习 文章目录 深度学习前言一、“Internal Covariate Shift”问题二、BatchNorm的本质思想三、训练阶段如何做BatchNorm四、BatchNorm的推理(Inference)过程五、BatchNorm的好处六、机器学习中mini-batch和batch有什么区别 前言 Batch Normalization作为最近一年来DL的重…...

uniapp实现文件预览过程

H5实现预览 <template><iframe :src"_url" style"width:100vw; height: 100vh;" frameborder"0"></iframe> </template> <script lang"ts"> export default {data() {return {_url: ,}},onLoad(option…...

深度学习-学习笔记记录

1、点云语义分割方法分类 分为5类&#xff1a;点、二维投影、体素、融合、集成 2、融合与集成的区别 融合&#xff1a; 概念&#xff1a;主要是将不同来源、类型的模型&#xff0c;例如深度学习、传统机器学习等&#xff0c;的结果或特征进行结合&#xff0c;以得到一个更好的模…...

程序员养生之道:延寿不忘初心——延寿必备

文章目录 每日一句正能量前言如何养生饮食篇运动篇休息篇后记 每日一句正能量 现代社会已不是大鱼吃小鱼的年代&#xff0c;而是快鱼吃慢鱼的年代。 前言 在IT行业中&#xff0c;程序员是一个重要的职业群体。由于长时间的繁重编程工作&#xff0c;程序员们常常忽略了身体健康…...

使用Docker安装部署Swagger Editor并远程访问编辑API文档

文章目录 Swagger Editor本地接口文档公网远程访问1. 部署Swagger Editor2. Linux安装Cpolar3. 配置Swagger Editor公网地址4. 远程访问Swagger Editor5. 固定Swagger Editor公网地址 Swagger Editor本地接口文档公网远程访问 Swagger Editor是一个用于编写OpenAPI规范的开源编…...

Nacos 2.X核心架构源码剖析

概述 注册中心并发处理&#xff0c;1.4.x 写时复制&#xff0c;2.1.0 读写分离&#xff1b;nacos 一般使用 AP 架构&#xff0c;即临时实例&#xff0c;1.4.x 为 http 请求&#xff0c;2.1.0 优化为 gRPC 协议&#xff1b;源码中使用了大量的事件通知机制和异步定时线程池&…...

C语言--每日选择题--Day31

第一题 1. 下面程序 i 的值为&#xff08;&#xff09; int main() {int i 10;int j 0;if (j 0)i; elsei--; return 0; } A&#xff1a;11 B&#xff1a;9 答案及解析 B if语句中的条件判断为赋值语句的时候&#xff0c;因为赋值语句的返回值是右操作数&#xff1b; …...

chrome vue devTools安装

安装好后如下图所示&#xff1a; 一&#xff1a;下载vue devTools 下载链接https://download.csdn.net/download/weixin_44659458/13192207?spm1001.2101.3001.6661.1&utm_mediumdistribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7EPaid-1-13192207…...

Spring Security 6.x 系列(7)—— 源码分析之Builder设计模式

一、Builder设计模式 WebSecurity、HttpSecurity、AuthenticationManagerBuilder 都是框架中的构建者&#xff0c;把他们放到一起看看他们的共同特点&#xff1a; 查看AuthenticationManagerBuilder的继承结构图&#xff1a; 查看HttpSecurity的继承结构图&#xff1a; 查看W…...

PyQt6 中自定义浮点型滑块类

介绍&#xff1a; 在PyQt6中&#xff0c;滑块&#xff08;Slider&#xff09;是常用的用户界面元素之一&#xff0c;用于选择数值范围。然而&#xff0c;有时候我们可能需要使用浮点数值&#xff0c;而标准的滑块仅支持整数。为了解决这个问题&#xff0c;我们可以创建一个自定…...

笔记,B+树

B树面对的场景&#xff0c;是一个有10亿行的表&#xff0c;希望某一列是有序的。这么大的数据量&#xff0c;内存里放不下&#xff0c;需要放在硬盘里。结果&#xff0c;原本运行于内存的二叉树&#xff0c;就升级为B树了。 在二叉树中&#xff0c;每个节点存储着一个数字&…...

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇&#xff0c;在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下&#xff1a; 【Note】&#xff1a;如果你已经完成安装等操作&#xff0c;可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作&#xff0c;重…...

<6>-MySQL表的增删查改

目录 一&#xff0c;create&#xff08;创建表&#xff09; 二&#xff0c;retrieve&#xff08;查询表&#xff09; 1&#xff0c;select列 2&#xff0c;where条件 三&#xff0c;update&#xff08;更新表&#xff09; 四&#xff0c;delete&#xff08;删除表&#xf…...

QMC5883L的驱动

简介 本篇文章的代码已经上传到了github上面&#xff0c;开源代码 作为一个电子罗盘模块&#xff0c;我们可以通过I2C从中获取偏航角yaw&#xff0c;相对于六轴陀螺仪的yaw&#xff0c;qmc5883l几乎不会零飘并且成本较低。 参考资料 QMC5883L磁场传感器驱动 QMC5883L磁力计…...

深入理解JavaScript设计模式之单例模式

目录 什么是单例模式为什么需要单例模式常见应用场景包括 单例模式实现透明单例模式实现不透明单例模式用代理实现单例模式javaScript中的单例模式使用命名空间使用闭包封装私有变量 惰性单例通用的惰性单例 结语 什么是单例模式 单例模式&#xff08;Singleton Pattern&#…...

全球首个30米分辨率湿地数据集(2000—2022)

数据简介 今天我们分享的数据是全球30米分辨率湿地数据集&#xff0c;包含8种湿地亚类&#xff0c;该数据以0.5X0.5的瓦片存储&#xff0c;我们整理了所有属于中国的瓦片名称与其对应省份&#xff0c;方便大家研究使用。 该数据集作为全球首个30米分辨率、覆盖2000–2022年时间…...

《用户共鸣指数(E)驱动品牌大模型种草:如何抢占大模型搜索结果情感高地》

在注意力分散、内容高度同质化的时代&#xff0c;情感连接已成为品牌破圈的关键通道。我们在服务大量品牌客户的过程中发现&#xff0c;消费者对内容的“有感”程度&#xff0c;正日益成为影响品牌传播效率与转化率的核心变量。在生成式AI驱动的内容生成与推荐环境中&#xff0…...

Keil 中设置 STM32 Flash 和 RAM 地址详解

文章目录 Keil 中设置 STM32 Flash 和 RAM 地址详解一、Flash 和 RAM 配置界面(Target 选项卡)1. IROM1(用于配置 Flash)2. IRAM1(用于配置 RAM)二、链接器设置界面(Linker 选项卡)1. 勾选“Use Memory Layout from Target Dialog”2. 查看链接器参数(如果没有勾选上面…...

从零开始打造 OpenSTLinux 6.6 Yocto 系统(基于STM32CubeMX)(九)

设备树移植 和uboot设备树修改的内容同步到kernel将设备树stm32mp157d-stm32mp157daa1-mx.dts复制到内核源码目录下 源码修改及编译 修改arch/arm/boot/dts/st/Makefile&#xff0c;新增设备树编译 stm32mp157f-ev1-m4-examples.dtb \stm32mp157d-stm32mp157daa1-mx.dtb修改…...

拉力测试cuda pytorch 把 4070显卡拉满

import torch import timedef stress_test_gpu(matrix_size16384, duration300):"""对GPU进行压力测试&#xff0c;通过持续的矩阵乘法来最大化GPU利用率参数:matrix_size: 矩阵维度大小&#xff0c;增大可提高计算复杂度duration: 测试持续时间&#xff08;秒&…...

06 Deep learning神经网络编程基础 激活函数 --吴恩达

深度学习激活函数详解 一、核心作用 引入非线性:使神经网络可学习复杂模式控制输出范围:如Sigmoid将输出限制在(0,1)梯度传递:影响反向传播的稳定性二、常见类型及数学表达 Sigmoid σ ( x ) = 1 1 +...