尚义住房和城乡规划建设局网站广告设计专业前景

news/2025/9/28 22:57:39/文章来源:
尚义住房和城乡规划建设局网站,广告设计专业前景,棉桃剥壳机做网站,商丘网站制作与设计文章目录 嫌啰嗦直接看源码Q5 :PyTorch on CIFAR-10three_layer_convnet题面解析代码输出 Training a ConvNet题面解析代码输出 ThreeLayerConvNet题面解析代码输出 Train a Three-Layer ConvNet题面解析代码输出 Sequential API: Three-Layer ConvNet题面解析代码输出 CIFAR-1… 文章目录 嫌啰嗦直接看源码Q5 :PyTorch on CIFAR-10three_layer_convnet题面解析代码输出 Training a ConvNet题面解析代码输出 ThreeLayerConvNet题面解析代码输出 Train a Three-Layer ConvNet题面解析代码输出 Sequential API: Three-Layer ConvNet题面解析代码输出 CIFAR-10 open-ended challenge题面解析代码输出 嫌啰嗦直接看源码 Q5 :PyTorch on CIFAR-10 three_layer_convnet 题面 让我们使用Pytorch来实现一个三层神经网络 解析 看下pytorch是怎么用的原理我们其实都清楚了自己去查下文档就好了 具体的可以看上一个cell上面给出的文档地址 For convolutions: http://pytorch.org/docs/stable/nn.html#torch.nn.functional.conv2d; pay attention to the shapes of convolutional filters!代码 def three_layer_convnet(x, params):Performs the forward pass of a three-layer convolutional network with thearchitecture defined above.Inputs:- x: A PyTorch Tensor of shape (N, 3, H, W) giving a minibatch of images- params: A list of PyTorch Tensors giving the weights and biases for thenetwork; should contain the following:- conv_w1: PyTorch Tensor of shape (channel_1, 3, KH1, KW1) giving weightsfor the first convolutional layer- conv_b1: PyTorch Tensor of shape (channel_1,) giving biases for the firstconvolutional layer- conv_w2: PyTorch Tensor of shape (channel_2, channel_1, KH2, KW2) givingweights for the second convolutional layer- conv_b2: PyTorch Tensor of shape (channel_2,) giving biases for the secondconvolutional layer- fc_w: PyTorch Tensor giving weights for the fully-connected layer. Can youfigure out what the shape should be?- fc_b: PyTorch Tensor giving biases for the fully-connected layer. Can youfigure out what the shape should be?Returns:- scores: PyTorch Tensor of shape (N, C) giving classification scores for xconv_w1, conv_b1, conv_w2, conv_b2, fc_w, fc_b paramsscores None################################################################################# TODO: Implement the forward pass for the three-layer ConvNet. ################################################################################## *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****x F.conv2d(x, conv_w1, biasconv_b1, padding2)x F.relu(x)x F.conv2d(x, conv_w2, biasconv_b2, padding1)x F.relu(x)x flatten(x)scores x.mm(fc_w) fc_b# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****################################################################################# END OF YOUR CODE #################################################################################return scores输出 注意这里需要注意有没有使用Gpu版本的pytorch,我就是在这里发现我的pytorch没有cuda Training a ConvNet 题面 解析 按照题面意思来就好了 代码 learning_rate 3e-3channel_1 32 channel_2 16conv_w1 None conv_b1 None conv_w2 None conv_b2 None fc_w None fc_b None################################################################################ # TODO: Initialize the parameters of a three-layer ConvNet. # ################################################################################ # *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****conv_w1 random_weight((channel_1, 3, 5, 5)) conv_b1 zero_weight(channel_1) conv_w2 random_weight((channel_2, channel_1, 3, 3)) conv_b2 zero_weight(channel_2) fc_w random_weight((channel_2 * 32 * 32, 10)) fc_b zero_weight(10)# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)***** ################################################################################ # END OF YOUR CODE # ################################################################################params [conv_w1, conv_b1, conv_w2, conv_b2, fc_w, fc_b] train_part2(three_layer_convnet, params, learning_rate)输出 ThreeLayerConvNet 题面 解析 就是让我们熟悉一下几个api 代码 class ThreeLayerConvNet(nn.Module):def __init__(self, in_channel, channel_1, channel_2, num_classes):super().__init__()######################################################################### TODO: Set up the layers you need for a three-layer ConvNet with the ## architecture defined above. ########################################################################## *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****self.conv1 nn.Conv2d(in_channel, channel_1, kernel_size5, padding2)self.conv2 nn.Conv2d(channel_1, channel_2, kernel_size3, padding1)self.fc3 nn.Linear(channel_2 * 32 * 32, num_classes)nn.init.kaiming_normal_(self.conv1.weight)nn.init.kaiming_normal_(self.conv2.weight)nn.init.kaiming_normal_(self.fc3.weight)# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****######################################################################### END OF YOUR CODE #########################################################################def forward(self, x):scores None######################################################################### TODO: Implement the forward function for a 3-layer ConvNet. you ## should use the layers you defined in __init__ and specify the ## connectivity of those layers in forward() ########################################################################## *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****x F.relu(self.conv1(x))x F.relu(self.conv2(x))scores self.fc3(flatten(x))# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****######################################################################### END OF YOUR CODE #########################################################################return scores输出 Train a Three-Layer ConvNet 题面 解析 就仿照上面的两层全连接改写就好了 关于optim 我试过sgd 和 adam,但是我发现还是sgd效果对于这个样本好一点。。。。 代码 learning_rate 3e-3 channel_1 32 channel_2 16model None optimizer None ################################################################################ # TODO: Instantiate your ThreeLayerConvNet model and a corresponding optimizer # ################################################################################ # *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****model ThreeLayerConvNet(in_channel3, channel_1channel_1, channel_2channel_2, num_classes10) optimizer optim.SGD(model.parameters(), lrlearning_rate)# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)***** ################################################################################ # END OF YOUR CODE # ################################################################################train_part34(model, optimizer)输出 Sequential API: Three-Layer ConvNet 题面 解析 也是仿照上面写就好了 代码 channel_1 32 channel_2 16 learning_rate 1e-2model None optimizer None################################################################################ # TODO: Rewrite the 2-layer ConvNet with bias from Part III with the # # Sequential API. # ################################################################################ # *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****model nn.Sequential(nn.Conv2d(in_channels3, out_channelschannel_1, kernel_size5, padding2),nn.ReLU(),nn.Conv2d(in_channelschannel_1, out_channelschannel_2, kernel_size3, padding1),nn.ReLU(),Flatten(),nn.Linear(channel_2 * 32 * 32, 10) ) optimizer optim.SGD(model.parameters(), lrlearning_rate, momentum0.9, nesterovTrue)# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)***** ################################################################################ # END OF YOUR CODE # ################################################################################train_part34(model, optimizer)输出 CIFAR-10 open-ended challenge 题面 就是让我们自己尝试搭建一种网络结构使其准确率大于70% 解析 自己试吧 代码 ################################################################################ # TODO: # # Experiment with any architectures, optimizers, and hyperparameters. # # Achieve AT LEAST 70% accuracy on the *validation set* within 10 epochs. # # # # Note that you can use the check_accuracy function to evaluate on either # # the test set or the validation set, by passing either loader_test or # # loader_val as the second argument to check_accuracy. You should not touch # # the test set until you have finished your architecture and hyperparameter # # tuning, and only run the test set once at the end to report a final value. # ################################################################################ model None optimizer None# *****START OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)*****model nn.Sequential(nn.Conv2d(3, 32, kernel_size3, stride1, padding1),nn.ReLU(),nn.MaxPool2d(kernel_size2, stride2),nn.Conv2d(32, 64, kernel_size3, stride1, padding1),nn.ReLU(),nn.MaxPool2d(kernel_size2, stride2),nn.Conv2d(64, 128, kernel_size3, stride1, padding1),nn.ReLU(),nn.MaxPool2d(kernel_size2, stride2),Flatten(),nn.Linear(128 * 4 * 4, 1024), ) optimizer optim.Adam(model.parameters(), lr1e-3)# *****END OF YOUR CODE (DO NOT DELETE/MODIFY THIS LINE)***** ################################################################################ # END OF YOUR CODE # ################################################################################# You should get at least 70% accuracy. # You may modify the number of epochs to any number below 15. train_part34(model, optimizer, epochs10)输出

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/921237.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

个人用云计算学习笔记 --15. (Linux 系统启动原理、Linux 防火墙管理)) - 实践

个人用云计算学习笔记 --15. (Linux 系统启动原理、Linux 防火墙管理)) - 实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-f…

给小孩出数学题

给小孩出数学题import java.util.Random; import java.util.Scanner; public class math_problems { public static void main(String[] args){ Random r=new Random(); Scanner sc=new Scanner(System.in); int probl…

dotnet项目编译运行

dotnet build - 基本构建 dotnet build PurestAdmin.Zero/PurestAdmin.Zero.csproj# 指定解决方案文件 dotnet build PurestAdmin.sln构建的常用参数 # 指定配置(Debug 或 Release) dotnet build --configuration Re…

linux virtualenv使用

在Linux系统中,virtualenv是一个用于创建虚拟环境的Python包。它允许你在不同的Python版本或不同的Python环境中安装和管理库。以下是如何在Linux中使用virtualenv的步骤:首先,确保你已经安装了Python。如果没有,请…

已有网站做google推广成都网站seo设计

0 软件开发人员自我成长 1 每天读2~3篇文章,可以行业趋势、技术类(和自己的工作有关的) 大厂技术博客科技资讯类:量子位、差评、新智元、无敌信息差 量子位、新智元经验分享、编程趋势、技术干活:程序员鱼皮、小林coding、java guide、程序…

实用指南:kafka详解

实用指南:kafka详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "…

06-基于FPGA和LTC2308的数字电压表设计-ModelSim仿真与Matlab模拟信号产生 - 详解

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

详细介绍:whisper-large-v3部署详细步骤,包括cpu和gpu方式,跟着做一次成功

详细介绍:whisper-large-v3部署详细步骤,包括cpu和gpu方式,跟着做一次成功2025-09-28 22:42 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-…

oracle_19c_ru_ojvm_upgrade.sh一键升级脚本分享

oracle_19c_ru_ojvm_upgrade.sh一键升级脚本分享2025-09-28 22:43 潇湘隐者 阅读(0) 评论(0) 收藏 举报oracle_19c_ru_ojvm_upgrade.sh脚本的初始版本来源于IT邦德的分享,使用原脚本时发现有一些bug,在我的环境中…

域名不变 网站改版如何知道网站开发语言

2019独角兽企业重金招聘Python工程师标准>>> 前景 Python在编程领域的占有率一直处于稳步上升之中,根据最新的数据,Python排名第六。前五名分别是 Java、C、PHP、C 和 VB. 作为一个很年轻的语言,Python的位置已经相当令人振奋了。…

数据类型-列表

列表 (可变类型):info= ["guohan",1,"222","xxx"] 公共功能:1.索引:  info[0]>>>"guohan"2.切片:  info[1;3]>>>[1,"222"]3步长:  …

2025/9/28

2025/9/28今日:1.学习离散数学 2.继续学习算法

网站内容页怎么设计网络优化行业怎么样

一、查看开机自启项1.Centos7自启项查看方式从Centos6的chkconfig改为:systemctl list-unit-files2.用grep过滤查看,比如:查看启动项:systemctl list-unit-files | grep enable查看sshd服务自启动情况:systemctl list-…

智表 ZCELL:纯前端 Excel 导入导出的高效解决方案,让数据处理更轻松

在当今数字化时代,数据处理已成为各行各业日常工作的重要组成部分,而 Excel 作为常用的数据处理工具,其导入导出功能的高效性和便捷性直接影响着工作效率。传统的 Excel 导入导出往往需要依赖后端服务,不仅流程繁琐…

采用IOT-Tree消息流MQTT模块节点实现监测数据推送功能

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

【MySQL 高阶】MySQL 架构与存储引擎全面详解 - 实践

【MySQL 高阶】MySQL 架构与存储引擎全面详解 - 实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas&quo…

两学一做网站进不去织梦物流公司网站模板简洁大气

图文:udb311主题:MSSQL内网渗透案例分析发表:黑白前线描述:对于内网渗透技术一直感觉很神秘,手中正巧有一个webshell是内网服务器。借此机会练习下内网入侵渗透技术!本文敏感信息以屏蔽!密码都以…

ISO 雨晨 26200.6588 Windows 11 企业版 LTSC 25H2 自用 edge 140.0.3485.81 - 教程

ISO 雨晨 26200.6588 Windows 11 企业版 LTSC 25H2 自用 edge 140.0.3485.81 - 教程pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; fo…

做淘宝美工图片网站常用的行业管理系统

一、概念: ①类似于仓库,空间内存储代码,需要用到时调用②也为防止名字冲突提供了更加可控的机制二、命名空间的定义 定义的基本格式如下:namespace 命名空间名 { //一系列声明与定义 };三、命名空间的注意事项 命名空间定义时最后的分号可有可无只要出现在全局作用域中的…

网站推广营销效果网站制作协议

建议对ionic和AnjularJs有一定了解的人可以用到,很多时候我们要用到选择省份、城市、区县的功能,现在就跟着我来实现这个功能吧,用很少的代码(我这里是根据客户的要求,只显示想要显示的部分省份和其相对应的城市、区县…