Practice teaching intelligent class program construction method

By adopting the PyTorch deep learning framework and structural programming strategy in intelligent programming practice, pre -define the experimental teaching sample templates, solve the problem of programming complexity caused by the different forms of open source code, and achieve a fast and convenient construction depth. Learning procedures have improved the quality of teaching and students' programming interests.

CN119356656APending Publication Date: 2025-01-24EAST CHINA NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411582452.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

In the practical teaching of intelligent programming, due to the different forms of open source code, it is difficult for students to quickly and conveniently build deep learning programs, which affects teaching efficiency and students' learning interest.

Method used

Adopt a structured programming strategy based on the PyTorch deep learning framework, pre -define the experimental teaching sample template, and build the steps of defining modules, model definition modules, training data definition modules, network training modules, and test data definition modules. Programming program.

Benefits of technology

The process of rapid and conveniently building deep learning in smart programming practice teaching has improved the quality of teaching quality and students' programming interests, and solves the problem of programming complexity caused by the different forms of open source code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356656A_ABST
    Figure CN119356656A_ABST
Patent Text Reader

Abstract

The invention discloses a practical teaching intelligent class program construction method, in practical teaching, based on pytorch programming, an experiment teaching sample template is constructed in advance, and the sample template comprises five component modules and two main program modules; the modules are respectively a parameter definition module p, a model definition module m, a network training module T, a training data definition module D1, a test data definition module D2, a training main module M1 and a test main module M2. A parameter definition module p, a model definition module m, a network training module T, a training data definition module D1 and a definition training main module M1 in the five component modules are used for model parameter training, and a test data definition module D2 and the model definition module m are combined to define a test main module M2 for performance test. According to the teaching content of each experiment, the programming content of the experiment can be quickly constructed by using the constructed experiment teaching sample template, and the teaching efficiency and quality are improved in practical teaching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology teaching, and is related to the problem of intelligent programming in practical teaching. It involves an effective method for constructing intelligent programs in practical teaching. By means of the deep learning programming framework of pytorch, a structured programming strategy is adopted, and experimental teaching sample templates are pre-defined. The program construction in the intelligent programming experiment can be conveniently and quickly realized, and the problems caused by the different forms of open source codes to the program writing of experimental teaching can be solved. Background Art

[0002] In recent years, with the rapid development of artificial intelligence technology, problems such as complex programs and different forms of open source codes have emerged in the practical teaching of intelligent programming. These problems have brought certain complexity to intelligent programming, which is mainly reflected in the following aspects: different contents of experiments are different, and in the process of referring to open source codes, the program styles and forms of reference codes are different, making it difficult to build programs conveniently and quickly in experimental teaching, causing students to lose interest in learning due to the difficulty of programming during the teaching process. Therefore, how to quickly and conveniently build deep learning programs in intelligent programming is a practical problem that needs to be solved in the practical teaching of intelligent classes. The solution to this problem is to utilize the rapid development of intelligent technology and the popularization and application of intelligent programming technology. Summary of the invention

[0003] The purpose of the present invention is to provide a method for constructing a practical teaching intelligent program, which can realize the rapid and convenient construction of a deep learning practical program and has high practical value.

[0004] The specific technical solution for achieving the purpose of the present invention is:

[0005] A method for constructing intelligent programs for practical teaching is characterized by being based on the pytorch deep learning framework. In the teaching process of intelligent programming, there are N intelligent programming contents. By following the following steps, the construction of intelligent programs can be effectively and quickly realized. The details are as follows:

[0006] Step 1: Build an experimental teaching sample template

[0007] First, a data set is established, and then, based on the data set, five component modules in the experimental teaching sample template are constructed:

[0008] 1) Build parameter definition module p

[0009] In the parameter definition module p, define the number of data batches and training iterations for model training;

[0010] 2) Build model definition module m

[0011] Define the specific network form of the model in the form of classes;

[0012] 3) Build training data definition module D1

[0013] The training data definition module D1 is defined as a training data class structure, including a training class constructor and a training class data item function: a) in the training class constructor, if supervised learning is used, each training data file name and the corresponding label file name in the training set are respectively constructed into a training data file name list L11 and a label file name list L12; otherwise, each training data file name in the data set is constructed into a training data file name list L13; b) in the training class data item function, if supervised learning is used, a training data and the corresponding label data in the training set are obtained from the training data file name list L11 or the label file name list L12, and used as the return value of the function; otherwise, a training data in the training set is obtained from the training data file name list L13, and used as the return value of the function;

[0014] 4) Construct network training module T

[0015] The network training module T is designed as a network training class, including a network training class constructor and a network training class training function: c) In the network training class constructor, the parameters of the constructor are used to complete the initialization of the training model, the number of data batches, the number of training iterations and the training data loader. In addition, the model optimizer is also initialized in the network training class constructor. If the training is continued based on the existing model parameters, the training class constructor also includes the initialization of the model parameters; d) For the network training class training function, it is designed as a loop structure. In the loop body of the loop structure, a batch of data is obtained by using the training class data item function through the training data loader, and the batch of data is input into the training model. According to the output result of the training model, the loss error is calculated, and according to the loss error, back propagation is performed, and the parameters of the training model are optimized in combination with the model optimizer; after executing d), the training model parameters S are saved;

[0016] 5) Build test data definition module D2

[0017] The test data definition module D2 is defined as a test data class structure, including a test class constructor and a test class data item function: e) in the test class constructor, if it is labeled test data, each test data file name and the corresponding label file name in the test set are respectively constructed into a test data file name list L21 and a label file name list L22; otherwise, each test data file name in the data set is constructed into a test data file name list L23; f) in the test class data item function, if it is labeled test data, a test data and the corresponding label data in the test set are obtained from the test data file name list L21 or the label file name list L22, and used as the return value of the function; otherwise, a test data in the test set is obtained from the test data file name list L23, and used as the return value of the function;

[0018] Create two main program modules:

[0019] 1) Build the training main module M1

[0020] In the training main module M1, first, the training parameters are obtained from the parameter definition module p, and then the network model class object is defined by using the model definition module m, and the training data class object is defined from the training data definition module D1, and further processed according to the following two steps: Step 1, according to the network training class, the network training class object is defined: the network training class constructor is called, and the training parameters, the network model class object and the training data class object are passed into the network training class as the actual parameters of the network training class object; Step 2, using the network training class object, the network training class training function is called to train the network model class object;

[0021] 2) Build and test the main module M2

[0022] In the test main module M2, first, the model parameter S is used to define the network test model, the model is initialized, and a test data loader is defined. During the test, the test data loader is used to take out the test data from the test class data item function, and then the test data is input into the network test model. When gradient calculation is disabled, the evaluation index of the model is calculated according to the output result of the network test model, and the evaluation index is printed out;

[0023] Step 2: Build a program for each experimental teaching content

[0024] In practical teaching, there are N intelligent programming contents. For each experimental teaching content, 5 component modules and 2 main program modules are constructed according to step 1, and the construction result of the experimental teaching program is obtained.

[0025] By using the method of the present invention, intelligent programming in practical teaching can be effectively, quickly and conveniently realized. In the practical teaching of intelligent programming, students' programming interests are guided, the quality of teaching is improved, and it is conducive to the rapid development of intelligent technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a flow chart of the method of the present invention;

[0027] Figure 2 A schematic diagram illustrating the effectiveness of the optical flow calculation program constructed using the method of the present invention. DETAILED DESCRIPTION

[0028] Example

[0029] The present invention is further described below in conjunction with the accompanying drawings.

[0030] This embodiment is implemented on a PC under Windows 10 64-bit operating system, and its hardware configuration is CPU i7-9700F, PC memory 16G, graphics card is GPU NVIDIA GeForce GTX 2070, video memory 8G. The deep learning framework uses pytorch1.8.1, programming uses Python3.7, and the experimental teaching of computer vision course is used as an example.

[0031] A method for constructing intelligent programs for practical teaching, based on the pytorch deep learning framework. In the process of computer vision experimental teaching, there are 8 intelligent programming contents: semantic segmentation experiment, image inpainting experiment, optical flow calculation, camera parameter recovery experiment, point cloud segmentation experiment, point cloud reconstruction experiment, target recognition experiment, and visual language model experiment. Follow the steps below to effectively and quickly construct the experimental teaching program:

[0032] Step 1: Build an experimental teaching sample template

[0033] Here we take the semantic segmentation experiment as an example.

[0034] Download the ACDC dataset from the website https: / / www.kaggle.com / datasets / jizongpeng / acdc2dall / data, and divide the sample data in the dataset into a training set and a test set in a ratio of 9:1. The data in the training set is used for training, and the data in the test set is used for testing.

[0035] Construct the five component modules in the semantic segmentation experiment teaching sample template:

[0036] 1) Build parameter definition module p

[0037] The parameter definition module p is defined in the config_loader.py file, which is placed in the configs folder of the semantic segmentation experiment example project. The specific design is:

[0038]

[0039] 2) Build model definition module m

[0040] Refer to the website https: / / github.com / bigmb / Unet-Segmentation-Pytorch-Nest-of-Unets to define the specific network form of the model, which is defined in the Unet.py file. The Unet.py file is placed in the model folder of the semantic segmentation experiment example project and is defined in the form of a class. The specific design is as follows:

[0041]

[0042]

[0043] 3) Build training data definition module D1

[0044] The training data definition module D1 is defined as a training data class MyDataset structure, which is defined in the dataset.py file in the root directory of the semantic segmentation experiment example project. The training data class MyDataset structure includes a training class constructor and a training class data item function: a) In the MyDataset class constructor, supervised learning is used to construct each training data file name and label file name in the training set into a training data file name list and a label file name list respectively; b) In the training class data item function, a training data and corresponding label data in the training set are obtained from the training data file name list and the label file name list, and a training data and corresponding label data are used as the return value of the function. The training data class MyDataset structure is specifically defined as:

[0045]

[0046]

[0047] 4) Construct network training module T

[0048] The network training module T is designed as a network training class Trainer, including a network training class constructor and a network training class training function train_model; the network training class Trainer is defined in the training.py file under the model folder of the semantic segmentation experiment example project; the training.py file is placed in the model folder of the semantic segmentation experiment example project; c) in the network training class constructor, the parameters of the constructor are used to complete the training model initialization, data batch number initialization, training iteration number initialization and training data loader initialization. In addition, the model optimizer initialization is also completed in the network training class constructor. If it is in the existing model parameters The training class constructor also includes the initialization of model parameters; d) for the network training class training function, it is designed as a loop structure. In the loop body of the loop structure, a batch of data is obtained by using the training class data item function through the training data loader, and the batch of data is input into the training model. According to the output result of the training model, the loss error is calculated, and according to the loss error, the back propagation is performed, and the parameters of the training model are optimized in combination with the model optimizer; after executing d), the training model parameters S are saved in the UNet.pth file in the root directory of the semantic segmentation experiment example project. The network training class Trainer is specifically defined as:

[0049]

[0050]

[0051] 5) Build test data definition module D2

[0052] The test data definition module D2 is defined as a test data class structure, including a test class constructor and a test class data item function: e) in the test class constructor, if it is labeled test data, each test data file name and the corresponding label file name in the test set are respectively constructed into a test data file name list L21 and a label file name list L22; otherwise, each test data file name in the data set is constructed into a test data file name list L23; f) in the test class data item function, if it is labeled test data, a test data and the corresponding label data in the test set are obtained from the test data file name list L21 or the label file name list L22, and used as the return value of the function; otherwise, a test data in the test set is obtained from the test data file name list L23, and used as the return value of the function;

[0053] In the semantic segmentation experiment example project, in the definition of the test data definition module D2, a code is shared with the training data class MyDataset in the training data definition module D1. During the test, the test data path and the data path of the corresponding label are used as class instantiation parameters;

[0054] Define 2 main program modules:

[0055] 1) Build the training main module M1

[0056] The training main module M1 is defined in the train.py file, and train.py is placed in the root directory of the semantic segmentation experiment example project. The training main module M1 is defined in the train.py file, and train.py is placed in the root directory of the semantic segmentation experiment example project. For the training main module M1, first, obtain the training parameters from the parameter definition module p, and then use the model definition module m to define the network model class object, and define the training data class object from the training data definition module D1, and further process according to the following two steps: Step 1, define the network training class object according to the network training class: call the network training class constructor, and pass the training parameters, the network model class object and the training data class object as the actual parameters of the network training class object into the network training class; Step 2, use the network training class object to call the network training class training function to train the network model class object;

[0057]

[0058]

[0059] 2) Build and test the main module M2

[0060] In the test main module M2, the test main module M2 is defined in the test.py file, and test.py is placed in the root directory of the semantic segmentation experiment example project. In the test main module M2, first, the network test model is defined using the model parameter S, the model is initialized, and a test data loader is defined. During the test process, the test data loader is used to retrieve the test data from the test class data item function, and then the test data is input into the network test model. When gradient calculation is disabled, the evaluation index of the model is calculated based on the output result of the network test model, and the evaluation index is printed out; the test main module M2 is specifically defined as:

[0061]

[0062]

[0063] The training main module M1 is executed to obtain the model parameter training result, and then the test main module M2 is executed to obtain the test result.

[0064] In this example, the hyperparameters of the experiment are as follows: the optimizer uses the Adam optimizer, and the learning rate of each network is 1e-3. Step 2: Build a program for each experimental teaching content

[0065] In the teaching process of computer vision courses, other intelligent programming content is based on the experimental teaching sample template constructed in step 1, and the program construction in the optical flow calculation experiment is selected as the instantiation:

[0066] Download the MPI-Sintel Dataset from https: / / www.kaggle.com / datasets / artemmmtry / mpi-sintel-dataset, and refer to the model structure of https: / / github.com / NVIDIA / flownet2-pytorch to build the five component modules and two main program modules mentioned above, that is, you can build a program for practical teaching of optical flow calculation:

[0067] 5 component modules:

[0068] 1) Build parameter definition module p

[0069] The parameter definition module p is defined in the config_loader.py file, which is placed in the configs folder of the optical flow calculation experiment example project. The specific design is:

[0070]

[0071] 2) Build model definition module m

[0072] Refer to the website https: / / github.com / NVIDIA / flownet2-pytorch to define the specific network form of the model, which is defined in the FlowNet2.py file. The FlowNet2.py file is placed in the model folder of the optical flow calculation example project and is defined in the form of a class. The specific design is as follows:

[0073]

[0074] 3) Build training data definition module D1

[0075] The training data definition module D1 is defined in the dataset.py file, which is in the root directory of the optical flow calculation experiment example project. The training data definition module D1 is defined as a training data class MyDataset structure, which includes a training class constructor and a training class data item function. The training data class MyDataset structure is specifically defined as:

[0076]

[0077]

[0078] 4) Construct network training module T

[0079] The network training module T is designed as a network training class Trainer, including a network training class constructor and a network training class training function train_model; the network training class Trainer is defined in the training.py file under the model folder of the optical flow calculation teaching experiment example project; the training.py file is placed in the model folder of the optical flow calculation teaching experiment example project; c) in the network training class constructor, the parameters of the constructor are used to complete the training model initialization, data batch number initialization, training iteration number initialization and training data loader initialization. In addition, the model optimizer initialization is also completed in the network training class constructor. If it is in an existing model Continue training based on the parameters, the training class constructor also includes the initialization of model parameters; d) For the network training class training function, it is designed as a loop structure. In the loop body of the loop structure, a batch of data is obtained by using the training class data item function through the training data loader, and the batch of data is input into the training model. According to the output result of the training model, the loss error is calculated, and according to the loss error, back propagation is performed, and the parameters of the training model are optimized in combination with the model optimizer; after executing d), the training model parameters S are saved in the flow.pth file in the root directory of the optical flow calculation teaching experiment example project. The network training class Trainer is specifically defined as:

[0080]

[0081]

[0082] 5) Build test data definition module D2

[0083] In the definition of the test data definition module D2, a code segment is shared with the training data class MyDataset in the training data definition module D1. During testing, the test data path and the data path of the corresponding label are used as class instantiation parameters;

[0084] Define 2 main program modules:

[0085] 1) Build the training main module M1

[0086] The training main module M1 is defined in the train.py file, and train.py is placed in the root directory of the optical flow calculation teaching experiment example project. For the training main module M1, first, obtain the training parameters from the parameter definition module p, and then use the model definition module m to define the network model class object, and define the training data class object from the training data definition module D1, and further process according to the following two steps: Step 1, define the network training class object according to the network training class: call the network training class constructor, and pass the training parameters, the network model class object and the training data class object as the actual parameters of the network training class object into the network training class; Step 2, use the network training class object to call the network training class training function to train the network model class object;

[0087]

[0088] 2) Build and test the main module M2

[0089] In the test main module M2, the test main module M2 is defined in the test.py file, and test.py is placed in the root directory of the optical flow calculation teaching experiment example project. In the test main module M2, first, the network test model is defined using the model parameter S2, the model is initialized, and a test data loader is defined. During the test process, the test data loader is used to take out the test data from the test class data item function, and then the test data is input into the network test model. When gradient calculation is disabled, the evaluation index of the model is calculated according to the output result of the network test model, and the evaluation index is printed out; the test main module M2 is specifically defined as:

[0090]

[0091]

[0092] The training main module M1 is executed to obtain the model parameter training result, and then the test main module M2 is executed to obtain the test result.

[0093] Figure 1The flowchart of the program constructed in the embodiment of the present invention.

[0094] In addition, the method of the present invention is used to construct an optical flow calculation experimental example program. The established data set contains 50 images, and a supervised training method is used for a total of 500 rounds of training. Figure 2 It is a schematic diagram of the effectiveness of the optical flow calculation program constructed by the method of the present invention, that is, the downward trend of the loss during training of the optical flow calculation program constructed by the method of the present invention. Figure 2 The left part is the loss result of the first 16 rounds in 500 rounds, and the right part is the loss result of the last 16 rounds in 500 rounds. It can be seen from the figure that the loss is decreasing very well, indicating that the optical flow calculation program constructed by the method of the present invention has good performance. In addition, after 500 rounds of training, the error of the optical flow prediction of the two images tested is 1.5036, indicating that the method of the present invention is relatively effective.

[0095] In addition, the method of the present invention is used for teaching, which improves the teaching quality. The practical link of the computer vision course is an important link, which has a great influence on students' learning interest. The course evaluation information of two years is obtained from the school database. Table 1 is the statistical information of the teaching quality of this course in the two-year evaluation. The method of the present invention was not used in 2022, and the method of the present invention was used for teaching in 2023. It can be seen that the method of the present invention is used for teaching, which improves the quality of teaching.

[0096] Table 1

[0097] time Course evaluation score Effective ranking of departments 2022 4.630 54 / 65 2023 4.878 15 / 71

Claims

1. A method for constructing a practical teaching intelligent program, characterized in that: The method comprises the following specific steps: Step 1: Build an experimental teaching sample template First, a data set is established, and then, based on the data set, five component modules in the experimental teaching sample template are constructed: 1) Construct parameter definition module p In the parameter definition module p, define the number of data batches and training iterations for model training; 2) Construct model definition module m Define the specific network form of the model in the form of classes; 3) Build training data definition module D1 The training data definition module D1 is defined as a training data class structure, including a training class constructor and a training class data item function: a) in the training class constructor, if supervised learning is used, each training data file name and the corresponding label file name in the training set are respectively constructed into a training data file name list L11 and a label file name list L12; otherwise, each training data file name in the data set is constructed into a training data file name list L13; b) in the training class data item function, if supervised learning is used, a training data and the corresponding label data in the training set are obtained from the training data file name list L11 and the label file name list L12, and used as the return value of the function; Otherwise, obtain a training data in the training set from the training data file name list L13 and use it as the return value of the function; 4) Construct network training module T The network training module T is designed as a network training class, including a network training class constructor and a network training class training function: c) In the network training class constructor, the parameters of the constructor are used to complete the initialization of the training model, the number of data batches, the number of training iterations and the training data loader. In addition, the model optimizer is also initialized in the network training class constructor. If the training is continued based on the existing model parameters, the training class constructor also includes the initialization of the model parameters; d) For the network training class training function, it is designed as a loop structure. In the loop body of the loop structure, a batch of data is obtained by using the training class data item function through the training data loader, and the batch of data is input into the training model. According to the output result of the training model, the loss error is calculated, and according to the loss error, back propagation is performed, and the parameters of the training model are optimized in combination with the model optimizer; after executing d), the training model parameters S are saved; 5) Build test data definition module D2 The test data definition module D2 is defined as a test data class structure, including a test class constructor and a test class data item function: e) In the test class constructor, if it is labeled test data, each test data file name and the corresponding label file name in the test set are respectively constructed into a test data file name list L21 and a label file name list L22; otherwise, each test data file name in the data set is constructed into a test data file name list L23; f) In the test class data item function, if it is labeled test data, a test data and the corresponding label data in the test set are obtained from the test data file name list L21 or the label file name list L22, and used as the return value of the function; otherwise, a test data in the test set is obtained from the test data file name list L23, and used as the return value of the function; Create two main program modules: 1) Build the training main module M1 In the training main module M1, first, the training parameters are obtained from the parameter definition module p, and then the network model class object is defined by using the model definition module m, and the training data class object is defined from the training data definition module D1, and further processed according to the following two steps: Step 1, according to the network training class, the network training class object is defined: the network training class constructor is called, and the training parameters, the network model class object and the training data class object are passed into the network training class as the actual parameters of the network training class object; Step 2, using the network training class object, the network training class training function is called to train the network model class object; 2) Build and test the main module M2 In the test main module M2, first, the model parameter S is used to define the network test model, the model is initialized, and a test data loader is defined. During the test, the test data loader is used to take out the test data from the test class data item function, and then the test data is input into the network test model. When gradient calculation is disabled, the evaluation index of the model is calculated according to the output result of the network test model, and the evaluation index is printed out; Step 2: Build a program for each experimental teaching content In practical teaching, there are N intelligent programming contents. For each experimental teaching content, 5 component modules and 2 main program modules are constructed according to step 1, and the construction result of the experimental teaching program is obtained.