利用Python与selenium自动化模拟登陆12306官网!

12306 项目编写测试用例+接口测试+自动化测试 综合应用测试部分的知识点,结合12306官网、拿个Offer 12306项目,集中在功能测试(XMind提测+用例编写)、接口测试(Java+TestNG、Python+Pytest、Apifox工具)、自动化测试(Selenium)等方面 阅读详情

前言:

近年来,12306的反爬越来越来严重,从一年前的 获取tk参数后到现在增加了 JS、CSS等加密方式!

目前大部分人利用的登陆方式都是利用selenium ,此文也不例外。

 

 

环境:

Windows

  python 3.6.5

模块:

selenium

  pyautogui

time

很多人学习python,掌握了基本语法过后,不知道在哪里寻找案例上手。

很多已经做案例的人,却不知道如何去学习更加高深的知识。

那么针对这三类人,我给大家提供一个好的学习平台,免费领取视频教程,电子书籍,以及课程的源代码!

QQ群:701698587

第一步:

  实例化一款浏览器,并进入到12306官网

图片

 

driver = webdriver.Chrome()
driver.get('https://kyfw.12306.cn/otn/resources/login.html')
driver.implicitly_wait(10)
driver.maximize_window()

 

第二步:

点击账号登陆

driver.find_element_by_xpath('//*[@id="J-userName"]').send_keys('123456')
driver.find_element_by_xpath('//*[@id="J-password"]').send_keys('123456')

图片

 

 

第三步:

  在输入框中,模拟输入账号密码:

driver.find_element_by_xpath('//*[@id="J-userName"]').send_keys('123456')
driver.find_element_by_xpath('//*[@id="J-password"]').send_keys('123456')

图片

 

第四步:

  当账号密码输入完毕后,我们应该要做的就是 模拟点击验证码图片了!

那么首先把图片下载下来:

yzm_code = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div[2]/div[3]/div')
yzm_code.screenshot('yzm.png')

 

图片

 

 

第五步:

  验证码下载下来后就可以为所欲为了,不管是对接打码平台也好,自己训练模型,或者利用代码模拟点击也是可以的!

前面两种方法根本没法讲,所以这里采用第三种方式,进行模拟点击。

  在这里 说说我们需要达到的效果,验证码上总共有8张图,那么我想达到的效果就是我输入1,2,3那么程序自动点击1,2,3三张图片。

  所以我们先获取到每个图片的中心点坐标,这里是有规律的,聪明人肯定一看就懂了。

  我这里这个是随便写的:

code = input('请输入验证码:')
time.sleep(5)
point_map = {
    '1': '40,45',
    '2': '116,53',
    '4': '257,50',
    '5': '40,121',
    '6': '116,133',
    '3': '185,52',
    '7': '185,132',
    '8': '257,130'}
def get_point(indexs):
    indexs = indexs.split(',')
    temp = []
    for index in indexs:
        temp.append(point_map[index])
        print(temp)
    return temp


temp = get_point(code)

这两串代码就不解释了,很基础的东西。最终的效果就是 输入1,2 那么得到的是一个列表:

[ '40,45','116,53']

记住,这个坐标只是 验证码图片上的坐标,不是整个屏幕的全局坐标!!!!

那么如何取全局坐标?验证码顶点(1206,428)+验证码的坐标,即全局坐标!这里的 (1206,428)请自行测试!

图片

 

第六步:

  模拟点击,利用到pyautogui这个模块。切记,利用此模块前一定要加延迟进行画面切换。

  (此文只做方法学习,并没有任何其它意思,正常情况都是对接打码平台!希望大家能学以致用,在其它的编程过程中用的到这些方法!)

for i in temp:
    indexs = i.split(',')
    x = int(indexs[0])
    y = int(indexs[1])
    pyautogui.click(1206+x, 428+y)

最后点击登录即可!

driver.find_element_by_xpath('//*[@id="J-login"]').click()
Python使用selenium模块模拟登录12306 selenium模块概述   selenium模块是基于浏览器自动化的一个模块。换句话说使用selenium可以让浏览器根据自己写的代码自动运行。   相应的语法   ·编写基于浏览器自动化的操作代码   ·发起请求:get(url)   ·标签定位:find系列的方法   ·标签交互:send_ keys( 'xxx')   ·执行js程序:excute _script( 'jsCode ')一前进,后退:back() ,forward()   ·关闭浏览器:quit()   ... 阅读详情

相关推荐

利用Python与selenium自动化模拟登陆12306官网

前言: 近年来,12306的反爬越来越来严重,从一年前的 获取tk参数后到现在增加了 JS、CSS等加密方式! 目前大部分人利用的登陆方式都是利用selenium ,此文也不例外。 环境: Windows **  python 3.6.5** 模块: selenium **  pyautogui** time 第一步: 实例化一款浏览器,并进入到12306官网 driver = webdriver.Chrome()driver.get('https://kyfw.12306.cn/otn/resource

zihong523的博客 246

基于 Python 和 Selenium 的 铁路12306 自动化购票全解析

本文介绍了如何通过Python和Selenium实现12306自动化购票,重点突破反检测配置、动态元素处理和多场景交互等技术难点。首先,通过修改浏览器启动参数,移除自动化特征,降低被12306识别的概率。其次,详细解析了登录模块、查询模块和预订模块的核心代码,包括用户输入与二次验证、日期处理与车次提取、时间匹配与订单提交等功能。此外,文章还提供了代码优化与最佳实践,如反检测增强、动态元素处理和异常处理,以提高脚本的稳定性和鲁棒性。最后,文章强调了法律风险和账号安全问题,建议仅用于学习用途

zjmdsb的博客 2934

Python + selenium自动化工具 + 滑块验证码+点选验证码,实现模拟登录“中国铁路网12306”

文章目录一、模拟登录“中国铁路网123061.引入库2.初始化。3.其余步骤:总结 一、模拟登录“中国铁路网12306 下面是完成本次小项目需要引入的库,导入的时候如果爆红,说明编写错误或未安装库,安装的所有过程省略。由于12306的点选验证码机器很难模拟点击,所以采用了人工打码平台-超级鹰。 1.引入库 代码如下(示例): #!/usr/bin/env python # coding:utf-8 import requests from PIL import Image from io import

qq_35083213的博客 3081

Selenium+Python对开源中国官网进行模拟登录

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33744854的博客 219

【Python】自动化实现高铁票监控与实时购票(2024年版文末附源码,订阅后源码可直取,不定期更新专栏

Selenium实现高铁票查询与监控购票(更新于24年附源码已测试可用,祝大家春节快乐,购票成功

PGwanban的博客 891

python 12306购票助手.zip

python实现的12306小助手,可以完成很多内部人员才能看到的购票信息。适合毕业论文使用。

python模拟登录12306_利用Python与selenium自动化模拟登陆12306官网!

近年来,12306的反爬越来越来严重,从一年前的 获取tk参数后到现在增加了 JS、CSS等加密方式!完整源代码:链接:https://pan.baidu.com/s/1MFS8hVhjq9F0eJc****H5w提取码:fp40目前大部分人利用的登陆方式都是利用selenium ,此文也不例外。环境:Windowspython 3.6.5模块:seleniumpyautoguitime第一步:实...

weixin_29022115的博客 323

Python如何基于selenium实现自动登录博客园

主要介绍了Python如何基于selenium实现自动登录博客园,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

python 大众点评模拟登陆_利用Python与selenium自动化模拟登陆12306官网!

前言:近年来,12306的反爬越来越来严重,从一年前的 获取tk参数后到现在增加了 JS、CSS等加密方式!目前大部分人利用的登陆方式都是利用selenium ,此文也不例外。环境: Windows  python 3.6.5模块: selenium  pyautogui time第一步:  实例化一款浏览器,并进入到12306官网driver = webdriver.Chrome()driver...

weixin_39751453的博客 527

[0352]基于JAVA的停车场收费智慧管理系统的设计与实现

其次,从经营管理层面考虑,本系统涵盖了丰富的月卡管理和财务结算功能,如月卡用户管理、缴费、注销、挂失、解挂、补办等全流程服务,以及临保和月保的结算汇总与欠费查询等功能,这不仅有助于规范停车场的日常运营管理,更能有效提高财务管理效率,降低运营成本,实现精细化、数字化的财务管控。综上所述,本课题计划研发的基于Java的停车场收费智慧管理系统将在现有研究成果的基础上,重点优化月卡用户全生命周期管理和财务统计分析功能,以满足现代停车场高效、精准、安全的管理需求,紧跟行业发展趋势,为推动智慧城市的建设贡献一份力量。

muyu2980的专栏 594

STM32F103+AX58100 EtherCAT从站SPI移植实战:CubeMX配置避坑指南

本文详细介绍了STM32F103与AX58100 EtherCAT从站控制器的SPI接口移植实战,重点解析CubeMX配置中的关键参数与常见陷阱。内容涵盖硬件连接规范、SPI模式设置、中断优先级规划及协议栈对接技巧,帮助开发者高效实现工业自动化领域的实时通信方案。特别强调CPOL/CPHA配置与AX58100的匹配要求,避免数据错位问题。

weixin_29230865的博客 351

Python3 爬虫实战 — 模拟登陆12306【点触验证码对抗】

登陆时间:2019-10-21 实现难度:★★★☆☆☆ 请求链接:https://kyfw.12306.cn/otn/resources/login.html 实现目标:模拟登陆中国铁路12306,攻克点触验证码 涉及知识:点触验证码的攻克、自动化测试工具 Selenium 的使用、对接在线打码平台 完整代码:https://github.com/TRHX/Python3-Spider-Pra...

BOB'S BLOG 4208

深度强化学习-D3QN算法原理与代码

Dueling Double Deep Q Network(D3QN)算法结合了Double DQN和Dueling DQN算法的思想,进一步提升了算法的性能。如果对Doubel DQN和Dueling DQN算法还不太了解的话,可以参考我的这两篇博文:深度强化学习-Doubel DQN算法原理与代码和深度强化学习-Dueling DQN算法原理与代码,分别详细讲述了这两个算法的原理以及代码实现。本文就带领大家了解一下D3QN算法,代码链接见下方。 代码:https://github.com/indigo

weixin_46133643的博客 2万+

Python爬虫学习之selenium项目1---12306模拟登录和验证码识别

Selenium是一款基于浏览器自动化的工具,使用它可以模拟浏览器进行网页访问,对于爬取一些动态加载数据的网站算是一个非常好用的工具了。 今天练习的项目就是基于Selenium对12306进行模拟登陆,并对其中的登陆验证码通过调用第三方平台超级鹰来进行自动识别点击,完成自动登陆。 一、首先,先对要爬取的网站12306进行一个分析。官方地址:https://www.12306.cn/index ...

qq_41174897的博客 1081

STM32H750xx【QSPI】轮询方式读写GD25Q64E

本文详细介绍了GD25Q64E其特性、引脚定义及功能说明,重点阐述了在STM32H750平台上通过CubeMX配置QuadSPI接口的步骤,包括时钟设置、参数优化等。文章提供了完整的BSP驱动开发流程,涵盖写使能、四线模式使能、ID读取、解除保护、扇区擦除、整片擦除、页编程和数据读取等关键功能实现,并通过读写测试验证了DummyCycles参数对数据准确性的影响。

honmy18的博客 1436

乐视三合一体感摄像头Windows开发全攻略:结构光深度相机从驱动到手势识别

深度摄像头作为计算机视觉的重要传感器,通过主动投射红外图案并分析其变形来获取场景深度,结构光方案因其近距离精度高、成本低,被广泛应用于体感交互、手势识别和互动投影等场景。这类设备在Windows平台上的开发通常需要借助通用中间件来屏蔽底层硬件差异,而OpenNI正是连接深度相机与上层应用的关键技术栈。本文以乐视三合一体感摄像头为例,详细梳理了在Windows环境下安装驱动、配置OpenNI与NiTE、读取深度流与彩色流、实现骨骼跟踪和指尖检测的完整路径,并总结了供电不足、深度图黑屏、彩色深度配准等常见问题的

weixin_34406086的博客 366

python识别验证码12306_selenium模拟登录12306官网 +超级鹰识别验证码

前言一、通过selenium自动登录12306官网from selenium import webdriverfrom time import sleepfrom PIL import Imagefrom selenium.webdriver import ActionChainsimport requestsfrom hashlib import md5#超级鹰第三方接口class Chaoji...

weixin_30774211的博客 221

网络管理与维护综合实训2:基于AD证书服务构建企业内部HTTPS安全访问体系

本实训项目通过在Windows Server 2022环境下搭建AD域、DNS服务和Web服务器,实现安全的企业网站访问。主要内容包括:在两台服务器上安装操作系统并配置网络;在S1服务器上部署活动目录域、证书服务和Web服务;创建两个网站(HTTP和HTTPS);配置DNS记录和SSL证书;设置防火墙规则限制HTTP访问而允许HTTPS访问。通过实践掌握了AD证书管理、DNS配置、Web服务器设置及防火墙规则配置等关键技能,为网站管理工作奠定了基础,同时认识到证书管理在Web安全中的重要性。

深耕计算机专业知识与技术。 1001

基于selenium实现12306半自动化抢票

基于selenium实现12306半自动化抢票 一、需求分析 打开12306官网 登录 (进入登录页面,扫码登录) 进入到个人主页 进入到购票页面   录入出发地   录入目的地   录入出发时间   点击查询   选择要购买的车次 如G8924,选择坐席(一等座、二等座)   判断是否有票,点击预定 确定乘车人、席别 提交订单 二、代码实现 导入模块 from selenium import webdriver from selenium.webdriver.

YIGU的博客 898

SAP ABAP CO核心扩展-ZCKMLQS 多物料工厂的评估数量结构报表(CKMLQS)

CKMLQS 只能查看单一物料工厂的评估数量结构,SAP 没有提供多物料工厂的评估数量结构报表。这篇文章将实现 CO核心扩展-ZCKMLQS 多物料工厂的评估数量结构报表。

SAP李斌,本人承诺所有原创文章均不使用任何AI生成技术,请大家放心阅读。 1101

字节跳动—— 机器学习面试岗位

一面1.自我介绍,项目介绍2.lightgbm GBDT xgb,问的超级细,可能持续了7 8分钟,XGB残差怎么用一次和二次梯度求,分裂点怎么求,思想原理是什么。XGB实际使用中重要的超参数,你们比赛中用的目标函数是什么,为什么lightgbm速度更快,其并行计算如何实现(这点没回答上)3.bagging boosting 的区别,谁是更关注方差 ,谁是更关注偏差4.如何防止过拟合,项目中用过哪些手段。

FPGA/MATLAB学习教程/源码/项目合作开发 1699

【Python自动化脚本】实现高铁票监控并成功购票(2024年版文末附源码地址

2024年更新)python实现高铁票查询与监控购票-源码已测试可用,祝大家春节快乐,购票成功!

PGwanban的博客 4667

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

python爬虫使用seleium+超级鹰+Image模块自动登录12306(附源码和登录视频)

利用代码自动登录12306官网是爬虫领域的经典行为,整个过程中的难点在于网站验证码的自动化突破,整个过程需要突破两个验证码的阻碍,一是文字选图,二是滑块。其中文字选图较为麻烦。但是还是有方法能够顺利进行网站的登录,代码一执行,直接会运行到登录后的界面。 首先需要实例化一个brower对象,用于驱动浏览器 browser = webdriver.Firefox(executable_path=r'D:\python\python安装\Scripts\geckodriver.exe') browser.g

weixin_42435368的博客 999

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

1每天Python小例-12306爬虫#WinError 2

注意事项:1.下载电脑对应版本的火狐驱动程序geckodriver.exe 2self.driver.visit(self.login_url)后加上 script = ‘Object.defineProperty(navigator,“webdriver”,{get:()=>undefined,});’ self.driver.execute_script(script) 不然登录界面滑动移块会报错 ...

weixin_42666224的博客 984

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 10个顶级Python实用库,推荐你试试!
下一篇: 几十个Python常用模块集合,掌握了你就是大佬!
Python编程_可乐
博客等级 码龄6年 917粉丝 100原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址