当前位置:网站首页>2022 Wu Enda machine learning specialization week 2 practice lab: linear expression
2022 Wu Enda machine learning specialization week 2 practice lab: linear expression
2022-06-28 10:13:00 【wuuucj】
Exercise 1
# UNQ_C1
# GRADED FUNCTION: compute_cost
def compute_cost(x, y, w, b):
""" Computes the cost function for linear regression. Args: x (ndarray): Shape (m,) Input to the model (Population of cities) y (ndarray): Shape (m,) Label (Actual profits for the cities) w, b (scalar): Parameters of the model Returns total_cost (float): The cost of using w,b as the parameters for linear regression to fit the data points in x and y """
# number of training examples
m = x.shape[0]
# You need to return this variable correctly
total_cost = 0
### START CODE HERE ###
total_cost = sum(pow((y-(x*w+b)),2))/(2*m)
### END CODE HERE ###
return total_cost
Exercise 2
# UNQ_C2
# GRADED FUNCTION: compute_gradient
def compute_gradient(x, y, w, b):
""" Computes the gradient for linear regression Args: x (ndarray): Shape (m,) Input to the model (Population of cities) y (ndarray): Shape (m,) Label (Actual profits for the cities) w, b (scalar): Parameters of the model Returns dj_dw (scalar): The gradient of the cost w.r.t. the parameters w dj_db (scalar): The gradient of the cost w.r.t. the parameter b """
# Number of training examples
m = x.shape[0]
# You need to return the following variables correctly
dj_dw = 0
dj_db = 0
### START CODE HERE ###
dj_dw = sum(x*(x*w+b-y))/m
dj_db = sum((x*w+b)-y)/m
### END CODE HERE ###
return dj_dw, dj_db
Video link :https://www.bilibili.com/video/BV19B4y1W76i
边栏推荐
- JVM family (2) - garbage collection
- Dotnet uses crossgen2 to readytorun DLL to improve startup performance
- 读取pdf图片并识别内容
- Application of X6 in data stack index management
- 一种跳板机的实现思路
- [NLP] this year's college entrance examination English AI score is 134. The research of Fudan Wuda alumni is interesting
- Dbeaver installation and use tutorial (super detailed installation and use tutorial)
- R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
- MySQL的开发环境和测试环境有什么区别??
- 在OpenCloudOS使用snap安装.NET 6
猜你喜欢

Resolution: overview of decentralized hosting solution

The boss asked me to write an app automation -- yaml file reading -- with the whole framework source code attached

Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"

Solve the problem that the value of the action attribute of the form is null when transferring parameters

代理模式(Proxy)

Bron filter Course Research Report

如图 用sql行转列 图一原表,图二希望转换后

TCP实战案例之即时通信、BS架构模拟

手把手教你处理 JS 逆向之 SVG 映射

Xiaomi's payment company was fined 120000 yuan, involving the illegal opening of payment accounts, etc.: Lei Jun is the legal representative, and the products include MIUI wallet app
随机推荐
Bridge mode
函数的分文件编写
丢弃 Tkinter!简单配置快速生成超酷炫 GUI!
As shown in the figure, the SQL row is used to convert the original table of Figure 1. Figure 2 wants to convert it
Fabric.js 笔刷到底怎么用?
Inventory of excellent note taking software: good-looking and powerful visual note taking software, knowledge map tools heptabase, hydrogen map, walling, reflect, infranodus, tiddlywiki
Unity AssetBundle资源打包与资源加载
PMP Exam key summary IX - closing
Unity AssetBundle asset packaging and asset loading
Django数据库操作以及问题解决
Adapter mode
云服务器MYSQL查询速度慢
读取pdf文字和excel写入操作
第六天 脚本与动画系统
Is it safe to open an account with the QR code of CICC securities? Tell me what you know
Naming rules and specifications for identifiers
[Unity][ECS]学习笔记(三)
Redis sentinel cluster main database failure data recovery ideas # yyds dry goods inventory #
再见!IE浏览器,这条路由Edge替IE继续走下去
dotnet 使用 Crossgen2 对 DLL 进行 ReadyToRun 提升启动性能