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

域名备案批量查询哈尔滨企业网站seo

域名备案批量查询,哈尔滨企业网站seo,广州平面设计线下培训班,wordpress 外观菜单概念 当应用梯度下降算法到具有 m 个训练样本的逻辑回归问题时,我们需要对每个样本计算梯度并进行平均,从而更新模型参数。这个过程通常称为批量梯度下降(Batch Gradient Descent)。 代码实现 import numpy as npdef sigmoid(z…

概念

当应用梯度下降算法到具有 m 个训练样本的逻辑回归问题时,我们需要对每个样本计算梯度并进行平均,从而更新模型参数。这个过程通常称为批量梯度下降(Batch Gradient Descent)。

代码实现

import numpy as npdef sigmoid(z):return 1 / (1 + np.exp(-z))def compute_loss(X, y, theta):m = len(y)h = sigmoid(X.dot(theta))loss = (-1/m) * np.sum(y * np.log(h) + (1 - y) * np.log(1 - h))return lossdef batch_gradient_descent(X, y, theta, learning_rate, num_iterations):m = len(y)losses = []for _ in range(num_iterations):h = sigmoid(X.dot(theta))gradient = X.T.dot(h - y) / mtheta -= learning_rate * gradientloss = compute_loss(X, y, theta)losses.append(loss)return theta, losses# 生成一些模拟数据
np.random.seed(42)
m = 100
n = 2
X = np.random.randn(m, n)
X = np.hstack((np.ones((m, 1)), X))
theta_true = np.array([1, 2, 3])
y = (X.dot(theta_true) + np.random.randn(m) * 0.2) > 0# 初始化参数和超参数
theta = np.zeros(X.shape[1])
learning_rate = 0.01
num_iterations = 1000# 执行批量梯度下降
theta_optimized, losses = batch_gradient_descent(X, y, theta, learning_rate, num_iterations)# 打印优化后的参数
print("优化后的参数:", theta_optimized)# 绘制损失函数下降曲线
import matplotlib.pyplot as plt
plt.plot(losses)
plt.xlabel('迭代次数')
plt.ylabel('损失')
plt.title('损失函数下降曲线')
plt.show()

使用了 m 个训练样本,而不是一个。我们首先定义了 sigmoid 函数和计算损失的函数 compute_loss,然后实现了 batch_gradient_descent 函数来执行批量梯度下降。

http://www.yidumall.com/news/24535.html

相关文章:

  • 中国知名企业的企业文化seo博客模板
  • python做网站php爱网站查询
  • 东莞网站建设是什么意思嘉兴优化公司
  • 网站设计网站建设专业铁力seo
  • 功能型网站百度网址大全旧版安装
  • wordpress做付费阅读seo品牌优化
  • 龙岗在线网站建设商务软文写作300字
  • 济宁君天建设公司网站seo入门基础知识
  • 做网站啦代理的方法seo博客网站
  • 网站排名易下拉技术正规考证培训机构
  • 网站开发语言在那看出来小广告清理
  • wordpress mip 模板搜索引擎优化百度
  • 搜网站技巧广告网站大全
  • 用word做网站相关论文百度搜索排名怎么做
  • 网上做批发那个网站好搜索排名优化软件
  • 福田官方网站网络营销专业好就业吗
  • 衡水微网站制作怎么做万词优化
  • 自己电脑做网站域名备案怎么让某个关键词排名上去
  • 图标wordpress大泽山seo快速排名
  • 网站建设需要什么免费ip地址网站
  • 网站建设维护人员岗位阳城seo排名
  • 专门做美食的网站网络推广工作内容
  • 四川省铁路建设有限公司网站武汉网站运营专业乐云seo
  • 建设网站运营成本常见的网络营销方法
  • 给手机开发网站全国疫情高峰感染高峰进度
  • 银川兴庆建设局网站百度一下就一个
  • 临沂seo顾问快速排名生客seo
  • raspberry wordpressaso优化哪家好
  • 网站新类型百度竞价是什么
  • 腾讯云做网站选哪个百度站长平台怎么用