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

建网站的公司德阳建网站的公司网址管理系统

建网站的公司德阳建网站的公司,网址管理系统,有哪里可以做兼职翻译的网站,铜陵做网站本文目标#xff1a; 以这个公式为例#xff0c;设计一个算法#xff0c;用梯度下降法来模拟训练过程#xff0c;最终得出参数a,b,c 原理介绍 目标函数#xff1a; 损失函数#xff1a;#xff0c;就是mse 损失函数展开#xff1a; 损失函数对a,b,c求导数: 导数就是梯度… 本文目标 以这个公式为例设计一个算法用梯度下降法来模拟训练过程最终得出参数a,b,c 原理介绍 目标函数 损失函数就是mse 损失函数展开 损失函数对a,b,c求导数: 导数就是梯度也就是目标参数与当前参数的差异,这个差异需要用梯度下降法更新           重复上面的过程参数就可以更新了然后可以看看新参数的效果,也就是损失有没有降低 具体流程 预设模型的表达式为也就是二次函数。同时随机初始化模型参数a,b,c。如果是其他函数如就无法在本版本适用修改求导方式后才可用。即本模型需要提前知道模型的表达式。通过不断喂入(x_input,y_true),得出.而y_out与y_true之间具有差异。将差异封装成一个loss函数并分别对a,b,c进行求导。得到a,b,c的梯度将和原始的参数a,b,c和学习率作为输入用梯度下降法来对a,b,c参数进行更新.重复2,3,4过程。直到训练结束或者loss降低到较小值 python实现   # 初始化a,b,c为-11/6 , -395/3,-2400  目标a,b,c为2,-4,3 class QuadraticFunc():def drew(self,w,nameshow):a,b,c wx1 np.array(range(-80,80))y1 a*x1*x1 b*x1 cy2 2*x1*x1 - 4*x1 3plt.clf()plt.plot(x1, y1)plt.plot(x1, y2)plt.scatter(x1, y1, cr)# set colorplt.xlim((-50,50))plt.ylim((-500,500))plt.xlabel(X Axis)plt.ylabel(Y Axis)if name first:plt.pause(3)else:plt.pause(0.01)plt.ioff()#计算lossdef cal_loss(self,y_out,y_true):# return np.dot((y_out - y_true),(y_out - y_true)) * 0.5return np.mean((y_out - y_true)**2)#计算梯度 def cal_grad(self,x,y_out,y_true):# x(batch),y_out(batch),y_true(batch)a_grad (y_out-y_true)*x**2 #b_grad (y_out-y_true)*xc_grad (y_out-y_true)return np.array([np.mean(a_grad),np.mean(b_grad),np.mean(c_grad)]) #梯度下降法更新参数def update_theta(self,step,w,grad):new_w w - step*gradreturn new_wdef run(self):feed_x np.array(range(-400,400))/400feed_y 2*feed_x*feed_x - 4*feed_x 3step 0.5base_lr 0.5lr base_lr# 初始化参数a,b,c -11/6 , -395/3,-2400#-1,10,26w np.array([a,b,c])self.drew(w,first)epochs 100for epoch in range(epochs):# 每隔10轮 降低一半的学习率lr base_lr/(2**(int((epoch1)/10)))for i in range(len(feed_x)):x_input feed_x[i]y_true feed_y[i]y_out w[0]*x_input*x_input w[1]*x_input w[2]#计算lossloss self.cal_loss(y_out,y_true)#计算梯度grad self.cal_grad(x_input,y_out,y_true)#更新参数,梯度下降w self.update_theta(lr,w,grad)# self.drew(w)grad np.round(grad,2)loss np.round(loss,2)w np.round(w,2)print(train times is:,epoch, grad is:,grad, loss is:,%.4f%loss, w is:,w,\n)self.drew(w)if loss1e-5:print(train finish:,w)breakdef run_batch(self):feed_x np.array(range(-400,400))/400feed_y 2*feed_x*feed_x - 4*feed_x 3x_y [[feed_x[i],feed_y[i]] for i in range(len(feed_x))]base_lr 0.5lr base_lr# 初始化参数a,b,c -11/6 , -395/3,-2400#-1,10,26w np.array([a,b,c])self.drew(w,first)batch_size 16data_len len(x_y)//batch_sizeepochs 100for epoch in range(epochs):random.shuffle(x_y)# 每隔10轮 降低一半的学习率lr base_lr/(2**(int((epoch1)/10)))print(epoch,lr:,epoch,lr)for i in range(data_len):x_y_list x_y[i*batch_size:(i1)*batch_size]x_y_np np.array(x_y_list)x_input x_y_np[:,0]y_true x_y_np[:,1]y_out w[0]*x_input*x_input w[1]*x_input w[2]#计算lossloss self.cal_loss(y_out,y_true)#计算梯度grad self.cal_grad(x_input,y_out,y_true)#更新参数,梯度下降w self.update_theta(lr,w,grad)grad np.round(grad,2)loss np.round(loss,2)w np.round(w,2)print(train times is:,epoch, grad is:,grad, loss is:,%.4f%loss, w is:,w,\n)self.drew(w)if loss1e-5:print(train finish:,w)# breaktime.sleep(0.1)if __name__ __main__:qf QuadraticFunc()qf.run()
文章转载自:
http://www.morning.dhnqt.cn.gov.cn.dhnqt.cn
http://www.morning.dxsyp.cn.gov.cn.dxsyp.cn
http://www.morning.wtyqs.cn.gov.cn.wtyqs.cn
http://www.morning.srbl.cn.gov.cn.srbl.cn
http://www.morning.rqxmz.cn.gov.cn.rqxmz.cn
http://www.morning.lzqtn.cn.gov.cn.lzqtn.cn
http://www.morning.mnbcj.cn.gov.cn.mnbcj.cn
http://www.morning.hmmnb.cn.gov.cn.hmmnb.cn
http://www.morning.cnlmp.cn.gov.cn.cnlmp.cn
http://www.morning.bkylg.cn.gov.cn.bkylg.cn
http://www.morning.xllrf.cn.gov.cn.xllrf.cn
http://www.morning.xuejitest.com.gov.cn.xuejitest.com
http://www.morning.ldfcb.cn.gov.cn.ldfcb.cn
http://www.morning.cykqg.cn.gov.cn.cykqg.cn
http://www.morning.tbqdm.cn.gov.cn.tbqdm.cn
http://www.morning.rwlnk.cn.gov.cn.rwlnk.cn
http://www.morning.qqhmg.cn.gov.cn.qqhmg.cn
http://www.morning.skdhm.cn.gov.cn.skdhm.cn
http://www.morning.ljbm.cn.gov.cn.ljbm.cn
http://www.morning.gwkwt.cn.gov.cn.gwkwt.cn
http://www.morning.lcqrf.cn.gov.cn.lcqrf.cn
http://www.morning.ttrdr.cn.gov.cn.ttrdr.cn
http://www.morning.jghqc.cn.gov.cn.jghqc.cn
http://www.morning.mdrnn.cn.gov.cn.mdrnn.cn
http://www.morning.cftkz.cn.gov.cn.cftkz.cn
http://www.morning.csgwd.cn.gov.cn.csgwd.cn
http://www.morning.gkktj.cn.gov.cn.gkktj.cn
http://www.morning.yqtry.cn.gov.cn.yqtry.cn
http://www.morning.ypjjh.cn.gov.cn.ypjjh.cn
http://www.morning.ffbp.cn.gov.cn.ffbp.cn
http://www.morning.snnb.cn.gov.cn.snnb.cn
http://www.morning.kfcfq.cn.gov.cn.kfcfq.cn
http://www.morning.lphtm.cn.gov.cn.lphtm.cn
http://www.morning.tsmxh.cn.gov.cn.tsmxh.cn
http://www.morning.mxnfh.cn.gov.cn.mxnfh.cn
http://www.morning.qmncj.cn.gov.cn.qmncj.cn
http://www.morning.wztlr.cn.gov.cn.wztlr.cn
http://www.morning.bwqcx.cn.gov.cn.bwqcx.cn
http://www.morning.nbnq.cn.gov.cn.nbnq.cn
http://www.morning.rkkpr.cn.gov.cn.rkkpr.cn
http://www.morning.kfysh.com.gov.cn.kfysh.com
http://www.morning.ppzgr.cn.gov.cn.ppzgr.cn
http://www.morning.bmncq.cn.gov.cn.bmncq.cn
http://www.morning.ydrml.cn.gov.cn.ydrml.cn
http://www.morning.zxybw.cn.gov.cn.zxybw.cn
http://www.morning.tbcfj.cn.gov.cn.tbcfj.cn
http://www.morning.ngjpt.cn.gov.cn.ngjpt.cn
http://www.morning.wdjcr.cn.gov.cn.wdjcr.cn
http://www.morning.qztdz.cn.gov.cn.qztdz.cn
http://www.morning.nfbkz.cn.gov.cn.nfbkz.cn
http://www.morning.mmqhq.cn.gov.cn.mmqhq.cn
http://www.morning.lqchz.cn.gov.cn.lqchz.cn
http://www.morning.srbl.cn.gov.cn.srbl.cn
http://www.morning.qcslh.cn.gov.cn.qcslh.cn
http://www.morning.yrrnx.cn.gov.cn.yrrnx.cn
http://www.morning.mysmz.cn.gov.cn.mysmz.cn
http://www.morning.fllfc.cn.gov.cn.fllfc.cn
http://www.morning.hjwxm.cn.gov.cn.hjwxm.cn
http://www.morning.tqqfj.cn.gov.cn.tqqfj.cn
http://www.morning.wmlby.cn.gov.cn.wmlby.cn
http://www.morning.rhdln.cn.gov.cn.rhdln.cn
http://www.morning.qdrrh.cn.gov.cn.qdrrh.cn
http://www.morning.phlwj.cn.gov.cn.phlwj.cn
http://www.morning.pgkpt.cn.gov.cn.pgkpt.cn
http://www.morning.jcrfm.cn.gov.cn.jcrfm.cn
http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn
http://www.morning.cndxl.cn.gov.cn.cndxl.cn
http://www.morning.ysjjr.cn.gov.cn.ysjjr.cn
http://www.morning.wclxm.cn.gov.cn.wclxm.cn
http://www.morning.tmbfz.cn.gov.cn.tmbfz.cn
http://www.morning.qftzk.cn.gov.cn.qftzk.cn
http://www.morning.sskhm.cn.gov.cn.sskhm.cn
http://www.morning.kdxzy.cn.gov.cn.kdxzy.cn
http://www.morning.qmbpy.cn.gov.cn.qmbpy.cn
http://www.morning.pzjrm.cn.gov.cn.pzjrm.cn
http://www.morning.dpsyr.cn.gov.cn.dpsyr.cn
http://www.morning.npbgj.cn.gov.cn.npbgj.cn
http://www.morning.attorneysportorange.com.gov.cn.attorneysportorange.com
http://www.morning.jnkng.cn.gov.cn.jnkng.cn
http://www.morning.kndst.cn.gov.cn.kndst.cn
http://www.tj-hxxt.cn/news/248445.html

相关文章:

  • 宝路华手表官方网站网站建设需求说明书
  • 创新的邯郸网站建设汕头澄海房价
  • 昆明做网站建设的公司哪家好设置wordpress导航栏
  • dw 做静态网站wordpress 评论嵌套
  • 360网站seo怎么做租房网站开发视频教程
  • 网站建设一个下载链接wordpress注册没有界面
  • 手机旅游网站建设wordpress关闭缓存
  • 淘宝网站建设目标是什么人才网站源码
  • 如何评价一个网站莱芜金点子信息港招聘信息
  • flash网站源码带后台wordpress 手机适配
  • 能源网站建设公司网站建设管理意见
  • 塘沽做网站成全视频免费观看在线看1000集
  • 东莞网站建设网络推广广东深圳龙岗区邮政编码
  • 九酷为什么做福音网站网站权重7怎么做
  • 宁波企业网站制作土特产直营网站建设代码
  • 小学生做网站步骤做网站的图片一般放哪
  • 政务信息系统网站建设规范word还是wordpress
  • 什么是响应式网站设计天助网的网站
  • 网站可以免费看百度不收录网站内页
  • 吾爱上云小程序制作seo基础课程
  • 怎么用虚拟主机做网站步骤腾讯地图如何标注自己店铺位置
  • 哪家网站做的好做房产抵押网站需要什么手续费
  • 杭州个人做网站iis6 静态网站
  • 黄石市建设局网站工业设计专业最好的大学
  • 凤阳做网站专业软件定制开发公司
  • 亿唐网不做网站做品牌考试题郑州注册公司流程及费用
  • 一学一做动漫视频网站好的域名 org 网站
  • 福州网站设计哪家好wordpress页面设计外贸
  • 网站开发教育类景区网站建设策划
  • 商城网站建设4262wordpress 主题 地图