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

wordpress相册轮播系统优化大师免费版

wordpress相册轮播,系统优化大师免费版,自己设置网站,网站个人和企业有什么区别1.通过多项式拟合交互探索概念 import math import numpy as np import torch from torch import nn from d2l import torch as d2l 2.使用三阶多项式来生成训练和测试数据的标签 max_degree 20 # 多项式的最大阶数 n_train, n_test 100, 100 # 训练和测试数据集大小 true…

1.通过多项式拟合交互探索概念

import math
import numpy as np
import torch
from torch import nn
from d2l import torch as d2l

2.使用三阶多项式来生成训练和测试数据的标签

max_degree = 20  # 多项式的最大阶数
n_train, n_test = 100, 100  # 训练和测试数据集大小
true_w = np.zeros(max_degree)  # 分配大量的空间
true_w[0:4] = np.array([5, 1.2, -3.4, 5.6])features = np.random.normal(size=(n_train + n_test, 1))
np.random.shuffle(features)
poly_features = np.power(features, np.arange(max_degree).reshape(1, -1))
for i in range(max_degree):poly_features[:, i] /= math.gamma(i + 1)  # gamma(n)=(n-1)!
# labels的维度:(n_train+n_test,)
labels = np.dot(poly_features, true_w)
labels += np.random.normal(scale=0.1, size=labels.shape)

3.查看样本

true_w, features, poly_features, labels = [torch.tensor(x, dtype=torch.float32) for x in [true_w, features, poly_features, labels]]features[:2], poly_features[:2, :], labels[:2]

4.实现函数来评估模型在给定数据集的损失

def evaluate_loss(net, data_iter, loss):"""评估给定数据集上模型的损失"""metric = d2l.Accumulator(2)for X, y in data_iter:out = net(X)y = y.reshape(out.shape)l = loss(out, y)metric.add(l.sum(), l.numel())return metric[0] / metric[1]

5.定义训练函数

def train(train_features, test_features, train_labels, test_labels,num_epochs=400):loss = nn.MSELoss()input_shape = train_features.shape[-1]net = nn.Sequential(nn.Linear(input_shape, 1, bias=False))batch_size = min(10, train_labels.shape[0])train_iter = d2l.load_array((train_features, train_labels.reshape(-1,1)),batch_size)test_iter = d2l.load_array((test_features, test_labels.reshape(-1,1)),batch_size, is_train=False)trainer = torch.optim.SGD(net.parameters(), lr=0.01)animator = d2l.Animator(xlabel='epoch', ylabel='loss', yscale='log',xlim=[1, num_epochs], ylim=[1e-3, 1e2],legend=['train', 'test'])for epoch in range(num_epochs):d2l.train_epoch_ch3(net, train_iter, loss, trainer)if epoch == 0 or (epoch + 1) % 20 == 0:animator.add(epoch + 1, (evaluate_loss(net, train_iter, loss),evaluate_loss(net, test_iter, loss)))print('weight:', net[0].weight.data.numpy())

http://www.dt0577.cn/news/42891.html

相关文章:

  • asp.net 4.0网站建设基础教程网络营销企业是什么
  • 湖南网站建设企业seo计费怎么刷关键词的
  • 可以做网站头像的图片网络营销技巧培训
  • 怎样用jsp做网站 新手教程谷歌商店安卓版下载
  • 徐州市网站建设seo优化上首页
  • 如何使用微信公众号做网站郑州模板网站建设
  • 网站开发技术的发展钦州seo
  • 义乌市建设局网站谷歌网站推广
  • 中企动力属于国企吗专业seo优化推广
  • 天津小程序网站开发公司小程序开发收费价目表
  • 外贸网站的建设搜索引擎推广的基本方法有
  • 长春做商业平台网站济南网站建设哪家好
  • 北京网站建设排名小程序开发文档
  • 网站开发语言更换seo营销技巧培训班
  • 青岛网站建设小公司排名网站开发步骤
  • wordpress模仿b站的主题天堂网
  • wordpress function requireseo北京优化
  • 毕业设计做网站做什么好爱站网关键词挖掘查询工具
  • 做网站收入怎么样千锋教育的官网
  • 做的网站 如何在局域网内访问如何优化网络速度
  • 欧洲男女做受视频网站广州头条新闻最新
  • 本地搭建php网站网站优化查询代码
  • 用ps怎么做网站导航条互联网营销方式
  • 网站内部结构优化公司网站优化方案
  • 微信小程序游戏开发一个多少钱太原seo报价
  • 众讯 网站建设百度查关键词显示排名
  • 威海做网站公司苏州百度 seo
  • 东莞网站建设外贸百度客服怎么联系
  • 网站可信度必须做吗seo关键词布局
  • 小学生个人网站怎么做网络营销概念是什么