day40训练与测试的规范写法

昨天我们介绍了图像数据的格式以及模型定义的过程,发现和之前结构化数据的略有不同,主要差异体现在2处

  1. 模型定义的时候需要展平图像
  2. 由于数据过大,需要将数据集进行分批次处理,这往往涉及到了dataset和dataloader来规范代码的组织

现在我们把注意力放在训练和测试代码的规范写法上

之前我们用mlp训练鸢尾花数据集的时候并没有用函数的形式来封装训练和测试过程,这样写会让代码更加具有逻辑-----隔离参数和内容。

  1. 后续直接修改参数就行,不需要去找到对应操作的代码
  2. 方便复用,未来有多模型对比时,就可以复用这个函数

这里我们先不写早停策略,因为规范的早停策略需要用到验证集,一般还需要划分测试集

  1. 划分数据集:训练集(用于训练)、验证集(用于早停和调参)、测试集(用于最终报告性能)。
  2. 在训练过程中,使用验证集触发早停。
  3. 训练结束后,仅用测试集运行一次测试函数,得到最终准确率。

测试函数和绘图函数均被封装在了train函数中,但是test和绘图函数在定义train函数之后,这是因为在 Python 中,函数定义的顺序不影响调用,只要在调用前已经完成定义即可。

@浙大疏锦行

最全的Teststand 教程(英文版)IntroductionIntroduction.................................................................................................................xiTechnical Support Options.........................................................................................xiiCourse Objectives.......................................................................................................xiiiCourse Description .....................................................................................................xiiiCourse Map.................................................................................................................xivItems You Need for this Course Module:...................................................................xvNote on Hands-On Exercises......................................................................................xviLesson 1Introduction to TestStandIntroduction.................................................................................................................1-1The Role of a Test Executive......................................................................................1-2The TestStand Goal ....................................................................................................1-3What is TestStand?.....................................................................................................1-4The TestStand Architecture........................................................................................1-5The Sequence Editor...................................................................................................1-6The Operator Interface................................................................................................1-7The TestStand Engine.................................................................................................1-8Module Adapters ........................................................................................................1-9The TestStand Architecture........................................................................................1-10Summary.....................................................................................................................1-13ExercisesExercise 1-1 Running a Sequence File..................................................................1-15Exercise 1-2A Running a Sequence File from the LabVIEWOperator Interface ............................................................................1-20Exercise 1-2B Running a Sequence File from theLabWindows/CVI Operator Interface..............................................1-25ContentsTestStand Development Course Manual iv www.ni.comLesson 2The TestStand EnvironmentIntroduction.................................................................................................................2-1What is a Sequence?...................................................................................................2-2Step Groups.................................................................................................................2-3TestStand Sequence Files ...........................................................................................2-4Debugging Tools.........................................................................................................2-5The TestStand Process Model.....................................................................................2-8The Default Process Model: Test UUTs Mode ..........................................................2-9TestStandModel.seq....................................................................................................2-10The Role of the Process Model within the TestStand Architecture............................2-11ExercisesExercise 2-1 Understanding the Sequence File.....................................................2-15Exercise 2-2 Running a Sequence File with Breakpoints andSingle Stepping.................................................................................2-21Exercise 2-3 Understanding the Process Model....................................................2-28Lesson 3Creating SequencesIntroduction.................................................................................................................3-1How to Create Test Sequences ...................................................................................3-2Action 1 : Specify the Adapter ...................................................................................3-3Action 2: Select the Step Type ...................................................................................3-4Step Types...................................................................................................................3-5Action 3: Specify the Test Module.............................................................................3-6Specifying the Module................................................................................................3-7Specifying the Module: Search Directories................................................................3-8Action 4: Configure Step Properties...........................................................................3-9Step Properties: General Tab......................................................................................3-10Step Properties: Preconditions....................................................................................3-11Step Properties: Run Options......................................................................................3-12Step Properties: Post Actions......................................................................................3-14Step Properties: Loop..................................................................................................3-15Step Properties: Expressions.......................................................................................3-17ExercisesExercise 3-1 Creating Steps in the Sequence Editor .............................................3-23Exercise 3-2 Configuring Loop Options ...............................................................3-34Exercise 3-3 Creating a Sequence.........................................................................3-38Exercise 3-4 Running Sequences in Parallel (Optional) .......................................3-58Contents© National Instruments Corporation v TestStand Development Course ManualLesson 4TestStand Parameters, Variables, and ExpressionsIntroduction.................................................................................................................4-1Parameters...................................................................................................................4-2Parameters: Passing data from top-level sequences to subsequences.........................4-3TestStand Variables....................................................................................................4-4Local Variables...........................................................................................................4-5Creating Locals Variables...........................................................................................4-6Sequence File Global Variables..................................................................................4-8Creating Sequence File Global Variables...................................................................4-9Station Globals............................................................................................................4-10The Expression Browser.............................................................................................4-11ExercisesExercise 4-1 Using Local Variables......................................................................4-19Exercise 4-2 Examine the Uses and Differences between Locals,File Globals, and Station Globals.....................................................4-22Exercise 4-3 Using Expressions to Change Step Properties..................................4-30Exercise 4-4 Passing Parameters...........................................................................4-39Exercise 4-5 Dynamically Selecting Which Sequence to Run..............................4-49Exercise 4-6 Using the UUT Serial Number to Determine WhichSequence to Run...............................................................................4-50Lesson 5Creating Test Modules in External EnvironmentsIntroduction.................................................................................................................5-1Creating Tests in External Application Development Environments (ADEs)...........5-2Methods of Data Transfer for TestStand ....................................................................5-3Method 1—Passing Parameters Directly Using Structures........................................5-3Using Clusters to Pass Data from LabVIEW..............................................................5-4Using Structures to Pass Data from LabWindows/CVI..............................................5-6Method 2—Passing Arbitrary Number of Parameters Directly..................................5-8Method 3—Using the ActiveX Automation API to Access Propertiesand Methods .............................................................................................................5-12What is ActiveX Automation?....................................................................................5-13Summary of ActiveX Automation..............................................................................5-14TestStand and ActiveX Automation...........................................................................5-15Using TestStand ActiveX Automation Functions in LabVIEW.................................5-16An Example of Using ActiveX Automation in LabVIEW.........................................5-17Using ActiveX Automation in LabWindows/CVI......................................................5-18An Example Of Using The TestStand API Instrument Driver InLabWindows/CVI.....................................................................................................5-19Using TestStand to Generate Code Templates...........................................................5-24Code Templates ..........................................................................................................5-25ContentsTestStand Development Course Manual vi www.ni.comExercisesExercise 5-1A Creating Pass/Fail Tests in LabVIEW..............................................5-27Exercise 5-1B Creating Pass/Fail Tests with LabWindows/CVI.............................5-33Exercise 5-1C Creating Pass/Fail Tests for the DLL FlexiblePrototype Adapter.............................................................................5-44Exercise 5-2A Creating Numeric Limit Tests with LabVIEW................................5-54Exercise 5-2B Creating Numeric Limit Tests withLabWindows/CVI.............................................................................5-59Exercise 5-2C Creating Numeric Limit Tests for the DLLFlexible Prototype Adapter...............................................................5-67Exercise 5-3A Debugging Tests Using LabVIEW...................................................5-80Exercise 5-3B Debugging Tests Using LabWindows/CVI......................................5-84Exercise 5-3C Debugging Tests that use the DLL FlexiblePrototype Adapter.............................................................................5-88Exercise 5-4A Using the ActiveX API in Code Moduleswith LabVIEW .................................................................................5-91Exercise 5-4B Using the ActiveX API in Code Moduleswith LabWindows/CVI ....................................................................5-100Exercise 5-4C Using the ActiveX API in Flexible DLL CodeModules............................................................................................5-110Exercise 5-5A Creating a Simple Test Using the LabVIEWStandard Prototype Adapter .............................................................5-122Exercise 5-5B Creating A Simple Test Using The C/CVIStandard Prototype Adapter .............................................................5-124Exercise 5-6A Passing Parameters from TestStand to LabVIEWusing The TestStand API..................................................................5-125Exercise 5-6B Passing Parameters from TestStand toLabWindows/CVI using The TestStand API...................................5-127Exercise 5-7 Passing Data Between TestStand and a TestModule Using the DLL Flexible Prototype Adapter........................5-129Lesson 6User ManagementIntroduction.................................................................................................................6-1The TestStand User Manager .....................................................................................6-2Default User Profiles in TestStand .............................................................................6-3Linking Windows System Users.................................................................................6-5ExerciseExercise 6-1 Setting User Login Access and Privileges........................................6-7...............
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值