Image-based auto-encoder training method, device, equipment and storage medium
By performing block encoding and fully connected layer sampling learning on medical images, combined with gradient descent training, the autoencoder model is optimized, solving the problem of low recovery accuracy of autoencoders after medical image decoding, and achieving higher decoding accuracy and morphological preservation.
Patent Information
- Application Number
- CN202310713710.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-15
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-06-15
AI Technical Summary
Existing autoencoders have low accuracy in recovering images after decoding during medical image recognition, and the probability of image distortion is relatively high.
The initial image is segmented into blocks, encoded using the ViT model, and sampled and learned by combining the mean and variance distributions of the first and second fully connected layers. The results of the third fully connected layer are then combined for vector concatenation and decoding. The model is trained using an image loss function and gradient descent to optimize the encoder model.
It improves the accuracy of image recovery after medical image decoding by autoencoders, ensuring that the image generated by the decoder is consistent with the original input in shape, uniform in shape, and reduces deformation.
Smart Images

Figure CN116664444B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to an image-based autoencoder training method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] Machine vision is an important component of the field of artificial intelligence, and the encoder that encodes images is the key to whether image features are extracted completely and accurately.
[0003] Currently, the industry generally uses an encoder-decoder model for autoencoder methods. The data is encoded by an encoder and then reconstructed by a decoder. After training, the autoencoder can extract features from data such as images, and these extracted text features can be used for image classification. However, because the features of images in the medical field are relatively complex, general image autoencoders often have low accuracy when reconstructing images after decoding, and the probability of image distortion is relatively high. Therefore, current autoencoder methods have low accuracy in medical image recognition. Summary of the Invention
[0004] This invention provides an image-based autoencoder training method, apparatus, device, and storage medium, the main purpose of which is to improve the accuracy of image autoencoders in recovering images after decoding medical images.
[0005] To achieve the above objectives, the present invention provides an image-based autoencoder training method, comprising:
[0006] Step A: Divide the pre-constructed initial image into blocks according to the preset resolution to obtain a set of image blocks, and use the pre-constructed encoder model to encode the set of image blocks to obtain a sequence of encoded features of a preset dimension.
[0007] Step B: Perform a full-connection operation on the encoded feature sequence using a pre-constructed first fully connected layer to obtain a first fully connected result, and perform an activation function mapping operation on the first fully connected result to obtain a first output value. Then, perform a full-connection operation on the encoded feature sequence using a pre-constructed second fully connected layer to obtain a second fully connected result, and perform an activation function mapping operation on the second fully connected result to obtain a second output value. Finally, according to a preset resampling strategy, resample the first output value and the second output value to obtain a first vector encoding of the preset dimension.
[0008] Step C: Perform a full connection operation on the encoded feature sequence using a pre-constructed third fully connected layer to obtain the third fully connected result, and concatenate the third fully connected result with the first vector encoding to obtain the second vector encoding;
[0009] Step D: Decode the second vector encoding using a pre-built decoder model to obtain the restored image;
[0010] Step E: Using a preset image loss function, calculate the loss value between the restored image and the initial image, and update the parameters of the encoder model according to the gradient descent method and the loss value to obtain the encoder model trained for the initial image.
[0011] Optionally, the preset image loss function is:
[0012] L = ||xy|| 2 +β*D KL [N(μ z , σ z ), N(0,1)]+γ*S(z)
[0013]
[0014] Where x is the restored image, y is the initial image, z is the first vector code, β and γ are preset hyperparameters, and μ z σ is the first output value. z This is the second output value; D KL Let B be the KL divergence, B be the batch size during training, i and j be the image labels in that batch, and z be the image index. i For the image labeled i, z j Image A is labeled j. ij Let be the similarity matrix of images i and j in the same batch.
[0015] Optionally, after obtaining the encoder model trained for the initial image, the method further includes:
[0016] Obtain a pre-constructed set of training sample images, select one of the sample images in the set of training sample images, and perform the above steps A to E to iteratively train the encoder model to obtain the encoder model corresponding to the selected sample image, and record the loss value corresponding to the sample image in sequence.
[0017] When the loss value is greater than or equal to the preset qualified threshold, or when the loss value does not converge, return to the above-mentioned selection of the next sample image in the training image sample image set, and execute the above-mentioned operation steps A to E.
[0018] When the loss value is less than the preset qualified threshold, or when the loss value converges, the training process stops, and the finally trained encoder model is obtained.
[0019] Optionally, after obtaining the finally trained encoder model, the method further includes:
[0020] Using training images of the same batch size as the encoder model, train a set of image classifiers for different application scenarios;
[0021] Based on a preset application scenario correspondence table, extract the image classifier corresponding to the target application scenario from the image classifier set;
[0022] By connecting the image classifier with the encoder model, an image classification model suitable for the target application scenario is obtained.
[0023] Optionally, updating the encoder model's parameters according to the gradient descent method and the loss value to obtain the encoder model trained for the initial image includes:
[0024] According to the gradient descent method, the loss value is minimized to obtain the set of parameter values of the encoder model, the decoder model, the first fully connected layer, the second fully connected layer, and the third fully connected layer when the loss value is minimized;
[0025] By reverse propagating through the network, the parameters of the encoder model, the decoder model, the first fully connected layer, the second fully connected layer, and the third fully connected layer are updated using the set of parameter values.
[0026] Optionally, before the step of dividing the pre-constructed initial image into blocks according to a preset resolution size, the method further includes:
[0027] The initial image is denoised using a mean filtering algorithm.
[0028] Optionally, both the encoder model and the decoder model are ViT models.
[0029] To address the above problems, the present invention also provides an image-based autoencoder training device, the device comprising:
[0030] The image primary encoding module is used to divide a pre-constructed initial image into blocks according to a preset resolution size to obtain an image block set, and to encode the image block set using a pre-constructed encoder model to obtain an encoded feature sequence of a preset dimension.
[0031] The vector sampling learning module is used to perform a fully connected operation on the encoded feature sequence using a pre-constructed first fully connected layer to obtain a first fully connected result, and to perform an activation function mapping operation on the first fully connected result to obtain a first output value; and to perform a fully connected operation on the encoded feature sequence using a pre-constructed second fully connected layer to obtain a second fully connected result, and to perform an activation function mapping operation on the second fully connected result to obtain a second output value; and to perform a resampling operation on the first output value and the second output value according to a preset resampling strategy to obtain a first vector encoding of the preset dimension.
[0032] The vector concatenation module is used to perform a full connection operation on the encoded feature sequence using a pre-constructed third fully connected layer to obtain a third fully connected result, and then concatenate the third fully connected result with the first vector encoding to obtain a second vector encoding.
[0033] The model training module is used to decode the second vector encoding using a pre-built decoder model to obtain a restored image, and to calculate the loss value between the restored image and the initial image using a preset image loss function, and to train the encoder model according to the gradient descent method and the loss value to obtain the trained encoder model corresponding to the initial image.
[0034] To address the above problems, the present invention also provides an electronic device, the electronic device comprising:
[0035] At least one processor; and,
[0036] A memory communicatively connected to the at least one processor; wherein,
[0037] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the image-based autoencoder training method described above.
[0038] To address the aforementioned problems, the present invention also provides a computer-readable storage medium storing at least one computer program, which is executed by a processor in an electronic device to implement the image-based autoencoder training method described above.
[0039] In this invention, the results of the first and second fully connected layers are used as the distribution of mean and variance for sampling learning, respectively. Combined with the results of the third fully connected layer, the image shape is preserved, ensuring that the decoder maintains rotational uniformity and shape when generating new images, making them as consistent as possible with the initial input image. This improves the accuracy of the image autoencoder in reconstructing images after decoding. Therefore, the image-based autoencoder training method, apparatus, device, and storage medium provided by this invention can improve the accuracy of image autoencoders in reconstructing images after decoding medical images. Attached Figure Description
[0040] Figure 1 This is a schematic flowchart of an image-based autoencoder training method provided in an embodiment of the present invention.
[0041] Figure 2 A detailed flowchart illustrating one step in an image-based autoencoder training method according to an embodiment of the present invention;
[0042] Figure 3 This is a functional block diagram of an image-based autoencoder training device provided in an embodiment of the present invention;
[0043] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the image-based autoencoder training method according to an embodiment of the present invention.
[0044] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0045] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0046] This application provides an image-based autoencoder training method. In this application, the execution entity of the image-based autoencoder training method includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the image-based autoencoder training method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0047] Reference Figure 1 The diagram shown illustrates a flowchart of an image-based autoencoder training method according to an embodiment of the present invention. In this embodiment, the image-based autoencoder training method includes steps S1 to S5:
[0048] S1. Divide the pre-constructed initial image into blocks according to the preset resolution to obtain a set of image blocks, and use the pre-constructed encoder model to encode the set of image blocks to obtain a preset dimension of encoded feature sequence.
[0049] In this embodiment of the invention, the initial image can be an image from the medical field, such as an image of the intracranial brain or an X-ray image of the human soft tissue structure. Since medical images contain numerous image features, this embodiment of the invention uses an image patching process to obtain image sets of patches, which helps increase the recognition rate of medical image features. In this embodiment of the invention, the preset resolution can be 7*7 pixels.
[0050] This invention obtains a coding feature sequence [CLS] of dimension d from all input encoder models ViT model of patches.
[0051] Furthermore, in this embodiment of the invention, before the step of dividing the pre-constructed initial image into blocks according to a preset resolution size, the method further includes:
[0052] The initial image is denoised using a mean filtering algorithm.
[0053] The mean filtering algorithm refers to a method that applies a template to a target pixel in an image, which includes its surrounding neighboring pixels (the eight pixels surrounding the target pixel constitute a filtering template, i.e., including the target pixel itself), and then uses the average value of all pixels in the template to replace the original pixel value. In this embodiment of the invention, the mean filtering algorithm can effectively reduce the amount of image data and increase the training speed before training the encoder.
[0054] S2. Perform a full-connection operation on the encoded feature sequence using a pre-constructed first fully connected layer to obtain a first fully connected result, and perform an activation function mapping operation on the first fully connected result to obtain a first output value. Then, perform a full-connection operation on the encoded feature sequence using a pre-constructed second fully connected layer to obtain a second fully connected result, and perform an activation function mapping operation on the second fully connected result to obtain a second output value. Finally, according to a preset resampling strategy, resample the first output value and the second output value to obtain a first vector encoding of the preset dimension.
[0055] In this embodiment of the invention, both the first fully connected layer and the second fully connected layer are composed of N fully connected layers, where N is 3. Furthermore, both activation functions are sigmoid activation functions.
[0056] In this embodiment of the invention, after the three fully connected layers, the sigmoid activation function maps the outputs of the first and second fully connected layers to a single value. Then, according to a preset resampling strategy, the output value of the first fully connected layer is used as the mean, and the output value of the second fully connected layer is used as the variance, forming a value with N(μ) z , σ z The probability distribution of the vector is resampled, and the resulting output is z, with the dimension of the z vector being d. Here, μ and σ represent the mean and variance, respectively. This resampling is a grayscale processing method in the reorganization of image data, a process of extracting low-resolution images from high-resolution images, which will not be elaborated upon here.
[0057] S3. Perform a full connection operation on the encoded feature sequence using a pre-constructed third fully connected layer to obtain a third fully connected result, and then concatenate the third fully connected result with the first vector encoding to obtain a second vector encoding.
[0058] In this embodiment of the invention, after the third fully connected layer outputs its result, it is not mapped using an activation function to obtain a third fully connected result with the same dimension d as the original. Then, the first vector encoding and the third fully connected result are concatenated to form a vector with a dimension of 2d.
[0059] This invention employs sampling and learning in the model using the distribution of the first and second output values as mean and variance, combined with the fully connected features of the third fully connected result, to ensure the shape of the image. This allows the decoder to maintain rotation and uniform shape when generating new images, making them as consistent as possible with the original input image.
[0060] S4. Use the pre-built decoder model to decode the second vector encoding to obtain the restored image.
[0061] In this embodiment of the invention, a 2D second vector is encoded and used as input to a decoder (ViT model). The decoder then decodes the vector to generate a new restored image. Both the encoder and decoder models are ViT models, but their parameters are independent.
[0062] S5. Using a preset image loss function, calculate the loss value between the restored image and the initial image, and update the parameters of the encoder model according to the gradient descent method and the loss value to obtain the encoder model trained for the initial image.
[0063] In this embodiment of the invention, the main training objective is to restore the original input image to the new image generated by the decoder. Therefore, the image loss function is designed as follows:
[0064] L = ||xy|| 2 +β*D KL [N(μ z , σ z ), N(0,1)]+γ*S(z)
[0065]
[0066] Where x is the restored image, y is the initial image, z is the first vector code, β and γ are preset hyperparameters, and μ z σ is the first output value. z This is the second output value; D KL Let B be the KL divergence, B be the batch size during training, i and j be the image labels in that batch, and z be the image index. i For the image labeled i, z j Image A is labeled j. ij Let be the similarity matrix of images i and j in the same batch.
[0067] In this embodiment of the invention, the ||xy|| 2 The Euclidean distance between the restored image and the initial image vector is D. KL [N(μ z , σ z [N(0,1)] is the KL divergence between data sampled with the first and second fully connected layers as the mean and variance, and data sampled with a distribution having a mean of 0 and a variance of 1. Furthermore, in the formula:
[0068]
[0069] B represents the size of a batch during training, and i and j represent the images in that batch. To calculate the similarity between the feature vectors of the restored image and the initial image in a training batch; and the A ij The similarity matrix is calculated to determine the relevance between every pair of images (including the image itself) within a batch. Therefore, S(z) can be represented as the similarity ratio between two images i and j relative to the overall similarity in a batch.
[0070] In this embodiment of the invention, hyperparameters β and γ were designed to be 0.3 and 0.7, respectively.
[0071] Further reference Figure 2 As shown in this embodiment of the invention, after obtaining the encoder model trained for the initial image, the method further includes steps S51 to S53:
[0072] S51. Obtain a pre-constructed set of training sample images, select one of the sample images in the set of training sample images, and perform the above steps S1 to S5 to iteratively train the encoder model to obtain the encoder model corresponding to the selected sample image.
[0073] S52 records the loss values corresponding to the sample images sequentially;
[0074] S53. Determine the magnitude and convergence of the loss value;
[0075] When the loss value is greater than or equal to the preset qualified threshold, or when the loss value does not converge, return to the above-mentioned selection of the next sample image in the training image sample image set, and execute the above-mentioned operation steps A to E.
[0076] When the loss value is less than the preset qualified threshold, or when the loss value converges, S54, stop the training process and obtain the finally trained encoder model.
[0077] In this embodiment of the invention, the training sample image set can also be medical images with many image features.
[0078] This invention minimizes the loss value using the gradient descent method and transmits the obtained model parameters inversely through the network to update the encoder model. The training progress of the encoder model is controlled by managing the magnitude and convergence of the loss value. Training is complete when the loss value is sufficiently small or stabilizes, resulting in the final trained encoder model.
[0079] Furthermore, in this embodiment of the invention, after obtaining the finally trained encoder model, the method further includes:
[0080] Using training images of the same batch size as the encoder model, a set of image classifiers corresponding to different application scenarios is trained; according to a preset application scenario correspondence table, an image classifier corresponding to the target application scenario is extracted from the set of image classifiers; the image classifier is connected to the encoder model to obtain an image classification model suitable for the target application scenario.
[0081] In this embodiment of the invention, after obtaining the trained encoder model, it is necessary to select different classifiers for subsequent image recognition, classification, and other functions according to different application scenarios to implement the model. Therefore, this embodiment of the invention requires training an image classifier with a training batch size equal to the current batch. Then, the classifier is connected to the encoder to form an image classification model, which can be put into use after only minor training adjustments.
[0082] For example, in this embodiment of the invention, when importing a batch of training images into the image classification model, feature vectors of all images in the batch can be obtained from the trained encoder. These feature vectors are then input into an MLP for image classification, using the cross-entropy loss function to complete fine-tuning training. After training the classification model, it can classify individual input images. For instance, the training images in the same batch size as the encoder model can be images of tissue necrosis, swelling, etc., thereby training an image classification model for detecting tissue inflammation.
[0083] This invention employs sampling and learning with the results of the first and second fully connected layers as the mean and variance distributions, respectively, and combines this with the result of the third fully connected layer. This ensures the image's shape remains consistent, allowing the decoder to maintain rotation and uniform shape when generating new images, making them as similar as possible to the initial input image. This improves the accuracy of the image autoencoder in reconstructing images after decoding. Therefore, this invention provides an image-based autoencoder training method that enhances the accuracy of image autoencoders in reconstructing images from decoded medical images.
[0084] like Figure 3 The diagram shown is a functional block diagram of an image-based autoencoder training device provided in an embodiment of the present invention.
[0085] The image-based autoencoder training device 100 of this invention can be installed in an electronic device. Depending on the functions implemented, the image-based autoencoder training device 100 may include an image primary encoding module 101, a vector sampling learning module 102, a vector concatenation module 103, and a model training module 104. The module described in this invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and which are stored in the memory of the electronic device.
[0086] In this embodiment, the functions of each module / unit are as follows:
[0087] The image primary encoding module 101 is used to divide the pre-constructed initial image into blocks according to a preset resolution size to obtain an image block set, and to encode the image block set using a pre-constructed encoder model to obtain an encoding feature sequence of a preset dimension.
[0088] The vector sampling learning module 102 is used to perform a fully connected operation on the encoded feature sequence using a pre-constructed first fully connected layer to obtain a first fully connected result, and to perform an activation function mapping operation on the first fully connected result to obtain a first output value; and to perform a fully connected operation on the encoded feature sequence using a pre-constructed second fully connected layer to obtain a second fully connected result, and to perform an activation function mapping operation on the second fully connected result to obtain a second output value; and to perform a resampling operation on the first output value and the second output value according to a preset resampling strategy to obtain a first vector encoding of the preset dimension.
[0089] The vector concatenation module 103 is used to perform a full connection operation on the encoded feature sequence using a pre-constructed third fully connected layer to obtain a third fully connected result, and then concatenate the third fully connected result with the first vector encoding to obtain a second vector encoding.
[0090] The model training module 104 is used to perform decoding operations on the second vector encoding using a pre-built decoder model to obtain a restored image, and to calculate the loss value between the restored image and the initial image using a preset image loss function, and to train the encoder model according to the gradient descent method and the loss value to obtain the encoder model trained for the initial image.
[0091] In detail, the modules in the image-based autoencoder training device 100 described in this application embodiment employ the same methods as described above. Figures 1 to 2 The method uses the same techniques as the image-based autoencoder training method described in the previous section and can produce the same technical effects, so it will not be repeated here.
[0092] like Figure 4 The diagram shown is a schematic diagram of the structure of an electronic device 1 that implements an image-based autoencoder training method according to an embodiment of the present invention.
[0093] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as an image-based autoencoder training program.
[0094] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device 1, connecting various components of the electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., executing image-based autoencoder training programs) and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0095] The memory 11 includes at least one type of readable storage medium, including flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a portable hard drive. In other embodiments, the memory 11 can be an external storage device of the electronic device, such as a plug-in portable hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. Furthermore, the memory 11 can include both internal and external storage units of the electronic device. The memory 11 can be used not only to store application software and various types of data installed on the electronic device, such as code for an image-based autoencoder training program, but also to temporarily store data that has been output or will be output.
[0096] The communication bus 12 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable communication between the memory 11 and at least one processor 10, etc.
[0097] The communication interface 13 is used for communication between the electronic device 1 and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, Bluetooth interface, etc.), typically used to establish communication connections between the electronic device and other electronic devices. The user interface may be a display, an input unit (such as a keyboard), or, optionally, a standard wired or wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device and to display a visual user interface.
[0098] Figure 4 Only electronic devices with components are shown; it will be understood by those skilled in the art that... Figure 4 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0099] For example, although not shown, the electronic device 1 may also include a power supply (such as a battery) to power various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 1 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0100] It should be understood that the embodiments described are for illustrative purposes only and are not limited to this structure in the scope of the patent application.
[0101] The image-based autoencoder training program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions, which, when run in the processor 10, can achieve the following:
[0102] Step A: Divide the pre-constructed initial image into blocks according to the preset resolution to obtain a set of image blocks, and use the pre-constructed encoder model to encode the set of image blocks to obtain a sequence of encoded features of a preset dimension.
[0103] Step B: Perform a full-connection operation on the encoded feature sequence using a pre-constructed first fully connected layer to obtain a first fully connected result, and perform an activation function mapping operation on the first fully connected result to obtain a first output value. Then, perform a full-connection operation on the encoded feature sequence using a pre-constructed second fully connected layer to obtain a second fully connected result, and perform an activation function mapping operation on the second fully connected result to obtain a second output value. Finally, according to a preset resampling strategy, resample the first output value and the second output value to obtain a first vector encoding of the preset dimension.
[0104] Step C: Perform a full connection operation on the encoded feature sequence using a pre-constructed third fully connected layer to obtain the third fully connected result, and concatenate the third fully connected result with the first vector encoding to obtain the second vector encoding;
[0105] Step D: Decode the second vector encoding using a pre-built decoder model to obtain the restored image;
[0106] Step E: Using a preset image loss function, calculate the loss value between the restored image and the initial image, and update the parameters of the encoder model according to the gradient descent method and the loss value to obtain the encoder model trained for the initial image.
[0107] Specifically, the specific implementation method of the processor 10 for the above instructions can be referred to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, and will not be repeated here.
[0108] Furthermore, if the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0109] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor of an electronic device, can perform the following:
[0110] Step A: Divide the pre-constructed initial image into blocks according to the preset resolution to obtain a set of image blocks, and use the pre-constructed encoder model to encode the set of image blocks to obtain a sequence of encoded features of a preset dimension.
[0111] Step B: Perform a full-connection operation on the encoded feature sequence using a pre-constructed first fully connected layer to obtain a first fully connected result, and perform an activation function mapping operation on the first fully connected result to obtain a first output value. Then, perform a full-connection operation on the encoded feature sequence using a pre-constructed second fully connected layer to obtain a second fully connected result, and perform an activation function mapping operation on the second fully connected result to obtain a second output value. Finally, according to a preset resampling strategy, resample the first output value and the second output value to obtain a first vector encoding of the preset dimension.
[0112] Step C: Perform a full connection operation on the encoded feature sequence using a pre-constructed third fully connected layer to obtain the third fully connected result, and concatenate the third fully connected result with the first vector encoding to obtain the second vector encoding;
[0113] Step D: Decode the second vector encoding using a pre-built decoder model to obtain the restored image;
[0114] Step E: Using a preset image loss function, calculate the loss value between the restored image and the initial image, and update the parameters of the encoder model according to the gradient descent method and the loss value to obtain the encoder model trained for the initial image.
[0115] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0116] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0117] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0118] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0119] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.
[0120] The blockchain referred to in this invention is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0121] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0122] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any specific order.
[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. An image-based autoencoder training method, characterized by, The method comprises: Step A: performing a block operation on a pre-constructed initial image according to a preset resolution size to obtain an image block set, and performing an encoding operation on the image block set by using a pre-constructed encoder model to obtain an encoding feature sequence of a preset dimension; Step B: performing a full connection operation on the encoding feature sequence by using a pre-constructed first full connection layer to obtain a first full connection result, performing an activation function mapping operation on the first full connection result to obtain a first output value, performing a full connection operation on the encoding feature sequence by using a pre-constructed second full connection layer to obtain a second full connection result, and performing an activation function mapping operation on the second full connection result to obtain a second output value, and performing a resampling operation on the first output value and the second output value according to a preset resampling strategy to obtain a first vector code of the preset dimension; Step C: performing a full connection operation on the encoding feature sequence by using a pre-constructed third full connection layer to obtain a third full connection result, and performing a splicing operation on the third full connection result and the first vector code to obtain a second vector code; Step D: performing a decoding operation on the second vector code by using a pre-constructed decoder model to obtain a restored image; Step E: calculating a loss value of the restored image and the initial image by using a preset image loss function, and updating parameters of the encoder model according to a gradient descent method and the loss value to obtain an encoder model trained corresponding to the initial image; The preset image loss function is: wherein, is the restored image, is the initial image, is the first vector encoding, and are preset hyperparameters, is the first output value, is the second output value; is the KL divergence, is the size of a batch in the training process, and are the picture labels in the batch, is the picture with the label , and is the picture with the label ; is the similarity matrix of the pictures i and j in the same batch. The updating of the parameters of the encoder model according to the gradient descent method and the loss value to obtain the encoder model trained corresponding to the initial image comprises: minimizing the loss value according to the gradient descent method to obtain a parameter value set of the encoder model, the decoder model, the first full connection layer, the second full connection layer and the third full connection layer when the loss value is the smallest; and updating the parameters of the encoder model, the decoder model, the first full connection layer, the second full connection layer and the third full connection layer by using the parameter value set through network reverse propagation.
2. The image-based autoencoder training method of claim 1, wherein, After obtaining the initial image corresponding to the trained encoder model, the method further comprises: obtaining a pre-constructed training sample image set, selecting one of the training sample image set, and performing the operation steps of steps A to E to iteratively train the encoder model to obtain an encoder model corresponding to the selected sample image, and sequentially recording the loss value corresponding to the sample image; when the loss value is greater than or equal to a preset qualified threshold or the loss value does not converge, returning to the above step of selecting the next sample image in the training sample image set and performing the operation steps of steps A to E; when the loss value is less than the preset qualified threshold or the loss value converges, stopping the training process to obtain a final trained encoder model.
3. The image-based autoencoder training method of claim 2, wherein, After obtaining the final trained encoder model, the method further comprises: Training a picture classifier set corresponding to different application scenarios by using training images with the same batch size as the encoder model; Extracting a picture classifier corresponding to a target application scenario from the picture classifier set according to a preset application scenario corresponding relationship table; Connecting the picture classifier with the encoder model to obtain an image classification model suitable for the target application scenario.
4. The image-based autoencoder training method of claim 1, wherein, Before the step of performing a blocking operation on the pre-constructed initial image according to a preset resolution size, the method further comprises: Performing noise reduction processing on the initial image by using a mean filtering algorithm.
5. The image-based autoencoder training method of claim 1, wherein, The encoder model and the decoder model are both ViT models.
6. An image-based autoencoder training apparatus for implementing the image-based autoencoder training method according to any one of claims 1 to 5, characterized by The device comprises: An image primary encoding module configured to perform a blocking operation on a pre-constructed initial image according to a preset resolution size to obtain a set of image blocks, and to perform an encoding operation on the set of image blocks by using a pre-constructed encoder model to obtain an encoding feature sequence of a preset dimension; A vector sampling learning module configured to perform a full connection operation on the encoding feature sequence by using a pre-constructed first full connection layer to obtain a first full connection result, and to perform an activation function mapping operation on the first full connection result to obtain a first output value, and to perform a full connection operation on the encoding feature sequence by using a pre-constructed second full connection layer to obtain a second full connection result, and to perform an activation function mapping operation on the second full connection result to obtain a second output value, and to perform a resampling operation on the first output value and the second output value according to a preset resampling strategy to obtain a first vector code of the preset dimension; A vector splicing module configured to perform a full connection operation on the encoding feature sequence by using a pre-constructed third full connection layer to obtain a third full connection result, and to perform a splicing operation on the third full connection result and the first vector code to obtain a second vector code; A model training module configured to perform a decoding operation on the second vector code by using a pre-constructed decoder model to obtain a restored image, and to calculate a loss value of the restored image and the initial image by using a preset image loss function, and to update parameters of the encoder model according to a gradient descent method and the loss value to obtain an encoder model trained for the initial image.
7. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected to the at least one processor in communication; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the image-based autoencoder training method of any one of claims 1 to 5.
8. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the image-based autoencoder training method of any one of claims 1 to 5.
Citation Information
Patent Citations
Medical image recognition model training method and device, equipment and storage medium
CN115205225A