WO2024067884A1 - 一种数据处理方法及相关装置 - Google Patents

一种数据处理方法及相关装置 Download PDF

Info

Publication number
WO2024067884A1
WO2024067884A1 PCT/CN2023/123636 CN2023123636W WO2024067884A1 WO 2024067884 A1 WO2024067884 A1 WO 2024067884A1 CN 2023123636 W CN2023123636 W CN 2023123636W WO 2024067884 A1 WO2024067884 A1 WO 2024067884A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
network
mapping relationship
neural network
units
Prior art date
Application number
PCT/CN2023/123636
Other languages
English (en)
French (fr)
Inventor
任晓哲
周平义
蒙新泛
王雅圣
魏建生
蒋欣
苏腾
韩凯
王云鹤
舒晗
许春景
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024067884A1 publication Critical patent/WO2024067884A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Definitions

  • the present application relates to the field of artificial intelligence, and in particular to a data processing method and related devices.
  • Artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
  • artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence.
  • Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
  • Another problem with this core issue is how to design and train such a costly model to give full play to its value, and at the beginning of the design, it is necessary to prepare for possible unknown usage scenarios in the future, because such a costly model cannot be retrained over and over again, so there needs to be some form that can save the results of previous training and be able to prepare for possible usage scenarios in the future.
  • a large-scale model can be divided into multiple network units. Corresponding network units are set for different input samples (such as different word vectors). When a certain input sample is used for model training, only the network unit corresponding to the input sample among the multiple network units is updated, and the updated network unit will be stored so that it can be called at the next update.
  • the present application provides a data processing method that can increase the size of a large-scale model itself and increase the scalability and flexibility of the large-scale model.
  • an embodiment of the present application provides a data processing method, the method comprising: determining one or more target network units corresponding to a target word vector token and a storage address of the one or more target network units according to a target mapping relationship, wherein the storage space corresponding to the storage address is located in a storage space outside a computing unit; obtaining the one or more target network units from the storage space corresponding to the storage address; the one or more target network units are used to construct a neural network; and according to the target word vector, executing a training process corresponding to the neural network through the computing unit.
  • the target network units in the large-scale model are stored in a storage location outside the computing unit, when the current training sample is the corresponding word vector, one or more corresponding target network units are extracted from the storage location outside the computing unit. Since the storage space of the storage location outside the computing unit can be set larger, the size of the large-scale model itself can be increased through storage and computing separation, and the scalability and flexibility of the large-scale model can be increased.
  • the target network unit is a feed forward network FFN.
  • the computing unit is a graphics processing unit GPU, a tensor processing unit TPU, or a neural network processor NPU.
  • the storage space corresponding to the storage address is located in a memory, a network storage, or a hard disk.
  • the target mapping relationship includes a first target mapping relationship
  • the first target mapping relationship indicates multiple word vectors and one or more network units corresponding to each word vector
  • the first target mapping relationship is specifically a mapping table.
  • mapping relationship between training samples (word vector tokens) and network units is constructed by hashing. Since one training sample in the hash can only correspond to one unique network unit, and since there is a numerical range limit in the hash, as the number of training samples increases, a large number of different training samples may correspond to the same network unit, which affects the accuracy of the trained model.
  • the mapping relationship between training samples (word vector tokens) and network units is recorded in a mapping table, so that one training sample can correspond to multiple network units, and since there is no numerical range limit, a large number of different training samples will not correspond to the same network unit, thereby increasing the accuracy of the trained model.
  • the training process corresponding to the target neural network is executed by the computing unit to obtain an updated target neural network, and the updated target neural network includes the updated one or more target network units.
  • the method also includes: updating the data in the storage space corresponding to the storage address according to the updated one or more target network units.
  • the method before determining one or more target network units corresponding to the target word vector and the storage address of the one or more target network units according to the target mapping relationship, the method also includes: receiving modification information from the user regarding a second target mapping relationship, wherein the second target mapping relationship includes multiple word vectors and a network unit corresponding to each word vector; and modifying the second target mapping relationship according to the modification information to obtain the target mapping relationship.
  • the modification information is used to indicate at least one of the following: deletion, replacement or addition of a network unit corresponding to at least one word vector in the second target mapping relationship; deletion, replacement or addition of a mapping relationship included in the second target mapping relationship, wherein the mapping relationship is a word vector and a network unit corresponding to the word vector.
  • the method before determining one or more target network units corresponding to the target word vector and the storage address of the one or more target network units according to the target mapping relationship, the method further includes: in the process of training the neural network through the target word vector, based on the degree of decrease in training loss being lower than a threshold, adding network units corresponding to the target word vector in the second target mapping relationship to obtain the target mapping relationship.
  • the degree of decrease in training loss is low, it can be said that the current performance of the model cannot be further improved.
  • the structure of the neural network can be changed by adding network units so that the training loss can continue to decrease.
  • the target mapping relationship includes multiple word units and a network unit corresponding to each word unit, and the method further includes:
  • network units corresponding to some word units are determined from multiple word units included in the target mapping relationship, and the network units corresponding to the some word units in the neural network after convergence are used to construct a target neural network; the target neural network is used to perform model inference.
  • the present application provides a data processing device, the device comprising:
  • a processing module used to determine one or more target network units corresponding to the target word vector token and storage addresses of the one or more target network units according to the target mapping relationship, wherein the storage space corresponding to the storage address is located in the storage space outside the computing unit;
  • the one or more target network units are used to construct a neural network
  • the model training module is used to perform the training process corresponding to the neural network through the computing unit according to the target word vector.
  • the target network unit is a feed forward network FFN.
  • the computing unit is a graphics processing unit GPU, a tensor processing unit TPU, or a neural network processor NPU.
  • the storage space corresponding to the storage address is located in a memory, a network storage, or a hard disk.
  • the target mapping relationship includes a first target mapping relationship
  • the first target mapping relationship indicates multiple word vectors and one or more network units corresponding to each word vector
  • the first target mapping relationship is specifically a mapping table.
  • the training process corresponding to the target neural network is performed by the computing unit to obtain an updated target neural network
  • the updated target neural network includes the updated one or more target network units
  • the processing module is further used to:
  • data in the storage space corresponding to the storage address is updated.
  • the processing module before determining, according to the target mapping relationship, one or more target network units corresponding to the target word vector and the storage addresses of the one or more target network units, the processing module is further used to:
  • the second target mapping relationship includes a plurality of word vectors and a network unit corresponding to each word vector;
  • the second target mapping relationship is modified according to the modification information to obtain the target mapping relationship.
  • the modification information is used to indicate at least one of the following:
  • mapping relationship included in the second target mapping relationship, wherein the mapping relationship is a word vector and a network unit corresponding to the word vector.
  • the processing module before determining, according to the target mapping relationship, one or more target network units corresponding to the target word vector and the storage addresses of the one or more target network units, the processing module is further used to:
  • the network unit corresponding to the target word vector in the second target mapping relationship is increased to obtain the target mapping relationship.
  • the target mapping relationship includes multiple word units and a network unit corresponding to each word unit, and the processing module is further used to:
  • network units corresponding to some word units are determined from multiple word units included in the target mapping relationship, and the network units corresponding to the some word units in the neural network after convergence are used to construct a target neural network; the target neural network is used to perform model inference.
  • an embodiment of the present application provides a data processing device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform any optional method as described in the first aspect above.
  • an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored.
  • the computer-readable storage medium is run on a computer, the computer executes the above-mentioned first aspect and any optional method.
  • an embodiment of the present application provides a computer program product, including code, which, when executed, is used to implement the above-mentioned first aspect and any optional method.
  • the present application provides a chip system, which includes a processor for supporting a data processing device to implement the functions involved in the above aspects, such as sending or processing the data involved in the above methods; or information.
  • the chip system also includes a memory, which is used to store program instructions and data necessary for executing the device or training the device.
  • the chip system can be composed of chips, or it can include chips and other discrete devices.
  • the present application also provides an image classification method and device, which helps to reduce the amount of calculation and parameters in image classification processing.
  • an image classification method comprising: obtaining an input feature map of an image to be processed; performing convolution processing on the input feature map according to M convolution kernels of a neural network to obtain candidate output feature maps of M channels, where M is a positive integer; performing matrix transformation on the M channels of the candidate output feature map according to N matrices to obtain output feature maps of N channels, wherein the number of channels of each matrix in the N matrices is less than M, N is greater than M, and N is a positive integer; classifying the image to be processed according to the output feature map to obtain a classification result of the image to be processed.
  • the M convolution kernels may be standard convolution kernels in an existing convolutional neural network.
  • the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map.
  • the number of channels of the input feature map of the image to be processed is C
  • the number of channels of the standard convolution kernel in the existing convolutional neural network is also C, that is, the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map, where C is a positive integer.
  • a small number of standard convolution kernels i.e., M convolution kernels
  • these small number of candidate feature maps are matrix transformed to obtain the required output feature maps
  • the number of standard convolution kernels is less than the number of standard convolution kernels in the existing convolutional neural network.
  • the number of channels of the matrix used in the matrix transformation is also smaller than the standard convolution kernel. Therefore, it helps to reduce the amount of computation and the amount of parameters of the neural network model, thereby reducing the amount of computation and the amount of parameters of the image classification processing.
  • the number of channels of each of the N matrices may be 1, or the number of channels of each of the N matrices may be greater than 1.
  • the N matrices include M groups of convolution kernels, and the M groups of convolution kernels respectively correspond to the M channels of the candidate output feature maps; performing matrix transformation on the M candidate output feature maps according to the N matrices to obtain output feature maps of N channels includes: according to each group of convolution kernels in the M groups of convolution kernels, convolving the corresponding channels among the M channels of the candidate output feature map to obtain the output feature maps of the N channels.
  • the convolution kernels in each of the M groups are A group of convolution kernels is used to convolve corresponding channels among the M channels of the candidate output feature map to obtain the output feature map of the N channels, including: according to each group of convolution kernels in the M groups of convolution kernels, a depth convolution is performed on the corresponding channels among the M channels of the candidate output feature map to obtain the output feature map of the N channels.
  • the convolution kernel of each group in the M groups of convolution kernels is the same as the convolution kernels of other groups in the M groups of convolution kernels.
  • the classifying the image to be processed according to the output feature map to obtain a classification result of the image to be processed includes: performing feature splicing on the candidate output feature map and the output feature map to obtain a feature splicing feature map, the number of channels of the feature splicing feature map is M+N; classifying the image to be processed according to the feature splicing feature map to obtain a classification result of the image to be processed.
  • the above-mentioned feature splicing may refer to the candidate output feature map and the output feature map forming a new feature map in the depth direction, that is, the above-mentioned feature splicing feature map.
  • the number of channels of the candidate output feature map is M, and the number of channels of the output feature map is N.
  • the candidate output feature map and the output feature map can be feature spliced to obtain a feature splicing feature map with a channel number of M+N.
  • Feature splicing can introduce more details (or features) into the output feature map through the identity feature mapping.
  • this identity mapping does not introduce additional parameters or calculations, so it can improve the image classification effect without increasing the number of parameters and calculations.
  • an image classification method comprising: obtaining an input feature map of an image to be processed; performing convolution processing on the input feature map according to M first convolution kernels of a neural network to obtain first candidate output feature maps of M channels, where M is a positive integer; performing matrix transformation on the M first candidate output feature maps according to K first matrices to obtain first output feature maps of K channels, wherein the number of channels of each of the K first matrices is less than M, K is greater than M, and K is a positive integer; performing convolution processing on the first output feature map according to P second convolution kernels of a neural network to obtain second candidate output feature maps of P channels, where P is a positive integer; performing matrix transformation on the P second candidate output feature maps according to N second matrices to obtain second output feature maps of N channels, wherein the number of channels of each of the N second matrices is less than P, N is greater than P, and N is a positive integer; classifying the image to be processed according to the second output feature map
  • the M first convolution kernels may be standard convolution kernels in an existing convolutional neural network.
  • the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map.
  • the number of channels of the input feature map of the image to be processed is C
  • the number of channels of the standard convolution kernel in the existing convolutional neural network is also C, that is, the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map, where C is a positive integer.
  • the P second convolution kernels may also be standard convolution kernels in existing convolutional neural networks.
  • convolution processing in an existing convolutional neural network is implemented by using a small number of standard convolution kernels and matrix transformations, which can effectively reduce the redundancy between the output feature maps, reduce the amount of computation and parameters of the neural network model, and thus reduce the amount of computation and parameters of image classification processing. Therefore, the image classification method in an embodiment of the present application can improve the image classification effect without increasing the amount of parameters and computation (or reducing the amount of parameters and computation).
  • the number of channels of each of the K first matrices may be 1, or the number of channels of each of the K first matrices may be greater than 1.
  • the number of channels of each of the N second matrices may be 1, or the number of channels of each of the N second matrices may be greater than 1.
  • the convolution processing of the first output feature map according to the P second convolution kernels of the neural network to obtain the second candidate output feature maps of P channels includes: performing a deep convolution on the first output feature map to obtain a deep convolution feature map; and convolution processing of the deep convolution feature map according to the P second convolution kernels to obtain the second candidate output feature map.
  • performing deep convolution on the first output feature map to obtain a deep convolution feature map includes: performing deep convolution on the first output feature map with a stride greater than 1 to obtain the deep convolution feature map.
  • classifying the image to be processed according to the second output feature map to obtain a classification result of the image to be processed includes: performing a residual connection on the input feature map and the second output feature map to obtain a residual connection feature map; classifying the image to be processed according to the residual connection feature map to obtain a classification result of the image to be processed.
  • more details can be introduced into the output feature map through residual connection, and the residual connection does not introduce additional parameters or calculation amount. Therefore, the image classification effect can be improved without increasing the number of parameters and calculation amount.
  • an image classification device comprising: an acquisition unit for acquiring an input feature map of an image to be processed; a convolution unit for performing convolution processing on the input feature map according to M convolution kernels of a neural network to obtain candidate output feature maps of M channels, where M is a positive integer; a matrix transformation unit for performing matrix transformation on the M channels of the candidate output feature map according to N matrices to obtain output feature maps of N channels, wherein the number of channels of each matrix in the N matrices is less than M, N is greater than M, and N is a positive integer; a classification unit for classifying the image to be processed according to the output feature map to obtain a classification result of the image to be processed.
  • the M convolution kernels may be standard convolution kernels in an existing convolutional neural network.
  • the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map.
  • the number of channels of the input feature map of the image to be processed is C
  • the number of channels of the standard convolution kernel in the existing convolutional neural network is also C, that is, the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map, where C is a positive integer.
  • a small number of standard convolution kernels i.e., M convolution kernels
  • these small number of candidate feature maps are matrix transformed to obtain the required output feature maps
  • the number of standard convolution kernels is less than the number of standard convolution kernels in the existing convolutional neural network.
  • the number of channels of the matrix used in the matrix transformation is also smaller than the standard convolution kernel. Therefore, it helps to reduce the amount of computation and the amount of parameters of the neural network model, thereby reducing the amount of computation and the amount of parameters of the image classification processing.
  • the number of channels of each of the N matrices may be 1, or the number of channels of each of the N matrices may be greater than 1.
  • the N matrices include M groups of convolution kernels, and the M groups of convolution kernels respectively correspond to the M channels of the candidate output feature map; the matrix transformation unit is specifically used to: according to each group of convolution kernels in the M groups of convolution kernels, convolve the corresponding channels among the M channels of the candidate output feature map to obtain the output feature map of the N channels.
  • the matrix transformation unit is specifically used to: perform deep convolution on the corresponding channels of the M channels of the candidate output feature map according to each group of convolution kernels in the M groups of convolution kernels to obtain the output feature map of the N channels.
  • the convolution kernel of each group in the M groups of convolution kernels is The kernel is the same as the convolution kernels of other groups in the M groups of convolution kernels.
  • the classification unit is specifically used to: perform feature splicing on the candidate output feature map and the output feature map to obtain a feature splicing feature map, the number of channels of the feature splicing feature map is M+N; classify the image to be processed according to the feature splicing feature map to obtain a classification result of the image to be processed.
  • the above-mentioned feature splicing may refer to the candidate output feature map and the output feature map forming a new feature map in the depth direction, that is, the above-mentioned feature splicing feature map.
  • the number of channels of the candidate output feature map is M, and the number of channels of the output feature map is N.
  • the candidate output feature map and the output feature map can be feature spliced to obtain a feature splicing feature map with a channel number of M+N.
  • Feature splicing can introduce more details (or features) into the output feature map through the identity feature mapping.
  • this identity mapping does not introduce additional parameters or calculations, so it can improve the image classification effect without increasing the number of parameters and calculations.
  • an image classification device comprising: an acquisition unit, configured to acquire an input feature map of an image to be processed; a first convolution unit, configured to perform convolution processing on the input feature map according to M first convolution kernels of a neural network to obtain first candidate output feature maps of M channels, where M is a positive integer; a first matrix transformation unit, configured to perform matrix transformation on the M first candidate output feature maps according to K first matrices to obtain first output feature maps of K channels, wherein the number of channels of each of the K first matrices is less than M, K is greater than M, and K is a positive integer; a second convolution unit, configured to perform convolution processing on the first output feature map according to P second convolution kernels of a neural network to obtain second candidate output feature maps of P channels, where P is a positive integer; a second matrix transformation unit, configured to perform matrix transformation on the P second candidate output feature maps according to N second matrices to obtain second output feature maps of N channels, wherein the number of channels of each
  • the M first convolution kernels may be standard convolution kernels in an existing convolutional neural network.
  • the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map.
  • the number of channels of the input feature map of the image to be processed is C
  • the number of channels of the standard convolution kernel in the existing convolutional neural network is also C, that is, the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map, where C is a positive integer.
  • the P second convolution kernels may also be standard convolution kernels in existing convolutional neural networks.
  • convolution processing in an existing convolutional neural network is implemented by using a small number of standard convolution kernels and matrix transformations, which can effectively reduce the redundancy between the output feature maps, reduce the amount of computation and parameters of the neural network model, and thus reduce the amount of computation and parameters of image classification processing. Therefore, the image classification method in an embodiment of the present application can improve the image classification effect without increasing the amount of parameters and computation (or reducing the amount of parameters and computation).
  • the number of channels of each of the K first matrices may be 1, or the number of channels of each of the K first matrices may be greater than 1.
  • the number of channels of each of the N second matrices may be 1, or the number of channels of each of the N second matrices may be greater than 1.
  • the image classification device further includes a deep convolution unit, configured to: perform deep convolution on the first output feature map to obtain a deep convolution feature map; and the second convolution unit The element is specifically used to: perform convolution processing on the depth convolution feature map according to the P second convolution kernels to obtain the second candidate output feature map.
  • the deep convolution unit is specifically used to: perform a deep convolution with a stride greater than 1 on the first output feature map to obtain the deep convolution feature map.
  • the image classification device also includes a residual connection unit, used to: perform residual connection on the input feature map and the second output feature map to obtain a residual connection feature map; the classification unit is specifically used to: classify the image to be processed according to the residual connection feature map to obtain a classification result of the image to be processed.
  • more details can be introduced into the output feature map through residual connection, and the residual connection does not introduce additional parameters or calculation amount. Therefore, the image classification effect can be improved without increasing the number of parameters and calculation amount.
  • an image classification device which includes: a memory for storing programs; a processor for executing the programs stored in the memory, and when the program stored in the memory is executed, the processor is used to execute the method in any one of the implementation modes of the first aspect or the second aspect above.
  • the processor in the fifth aspect can be a central processing unit (CPU) or a combination of a CPU and a neural network processor, where the neural network processor can include a graphics processing unit (GPU), a neural network processor (NPU) and a tensor processing unit (TPU), etc.
  • the neural network processor can include a graphics processing unit (GPU), a neural network processor (NPU) and a tensor processing unit (TPU), etc.
  • GPU graphics processing unit
  • NPU neural network processor
  • TPU tensor processing unit
  • TPU is a dedicated integrated circuit for artificial intelligence accelerators fully customized by Google for machine learning.
  • a computer-readable medium which stores a program code for execution by a device, wherein the program code includes a method for executing any one of the implementations of the first aspect or the second aspect.
  • a computer program product comprising instructions
  • the computer program product when the computer program product is run on a computer, the computer is enabled to execute a method in any one of the implementations of the first or second aspect above.
  • a chip comprising a processor and a data interface, wherein the processor reads instructions stored in a memory through the data interface to execute a method in any one of the implementations of the first or second aspect.
  • the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory.
  • the processor is used to execute the method in any one of the implementation methods of the first aspect or the second aspect.
  • the above-mentioned chip can specifically be a field-programmable gate array (FPGA) or an application-specific integrated circuit (ASIC).
  • FPGA field-programmable gate array
  • ASIC application-specific integrated circuit
  • an electronic device which includes the image classification device in any one of the third aspect or the fourth aspect.
  • the electronic device may specifically be a terminal device or a server.
  • a small number of standard convolution kernels i.e., M convolution kernels
  • these small number of candidate feature maps are matrix transformed to obtain the required output feature maps
  • the number of standard convolution kernels is less than the number of standard convolution kernels in the existing convolutional neural network.
  • the number of channels of the matrix used in the matrix transformation is also smaller than the standard convolution kernel. Therefore, it helps to reduce the amount of computation and the amount of parameters of the neural network model, thereby reducing the amount of computation and the amount of parameters of the image classification processing.
  • FIG1 is a schematic diagram of a structure of an artificial intelligence main framework
  • FIG2 is a schematic diagram of the application system framework of the present invention.
  • FIG3 is a schematic diagram of the application system framework of the present invention.
  • FIG4A is a schematic diagram of a network structure
  • FIG4B is a schematic diagram of a network structure
  • FIG5 is a flow chart of a data processing method
  • FIG6 is a flowchart of a data processing method
  • FIG7 is a flow chart of a data processing method
  • FIG8 is a flow chart of a data processing method
  • FIG9 is a flow chart of a data processing method
  • FIG10 is a flow chart of a data processing method
  • FIG11 is a flow chart of a data processing method
  • FIG12 is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application.
  • FIG13 is a schematic diagram of an execution device provided in an embodiment of the present application.
  • FIG14 is a schematic diagram of a training device provided in an embodiment of the present application.
  • FIG15 is a schematic diagram of a chip provided in an embodiment of the present application.
  • FIG. 16 is a schematic diagram of the structure of the system architecture provided in an embodiment of the present application.
  • Figure 17 is a schematic diagram of image classification based on a convolutional neural network model provided in an embodiment of the present application.
  • FIG. 18 is a schematic diagram of a chip hardware structure provided in an embodiment of the present application.
  • FIG. 19 is a schematic diagram of an application scenario provided in an embodiment of the present application.
  • FIG. 20 is a schematic flowchart of an image classification method provided in one embodiment of the present application.
  • Figure 21 is a schematic block diagram of the convolution processing provided in an embodiment of the present application.
  • Figure 22 is a schematic block diagram of the feature amplification unit provided in an embodiment of the present application.
  • FIG. 23 is a schematic flowchart of an image classification method provided in another embodiment of the present application.
  • Figure 24 is a schematic block diagram of a spindle module provided by an embodiment of the present application.
  • FIG. 25 is a schematic block diagram of a spindle module provided in another embodiment of the present application.
  • FIG26 is a schematic block diagram of a neural network provided in an embodiment of the present application.
  • FIG. 27 is a schematic diagram of the hardware structure of the image classification device according to an embodiment of the present application.
  • FIG28 is a schematic diagram of the hardware structure of a neural network training device according to an embodiment of the present application.
  • Figure 1 shows a structural diagram of the main framework of artificial intelligence.
  • the following is an explanation of the above artificial intelligence theme framework from the two dimensions of "intelligent information chain” (horizontal axis) and “IT value chain” (vertical axis).
  • the "intelligent information chain” reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom".
  • the "IT value chain” reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
  • the infrastructure provides computing power support for the artificial intelligence system, enables communication with the outside world, and is supported by the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips (CPU, NPU, GPU, ASIC, FPGA and other hardware acceleration chips); the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
  • smart chips CPU, NPU, GPU, ASIC, FPGA and other hardware acceleration chips
  • the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc.
  • sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
  • the data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence.
  • the data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
  • Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
  • machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
  • Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
  • Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
  • some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
  • Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical applications. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
  • the embodiments of the present application can be applied to the field of information recommendation, which scenarios include but are not limited to scenarios involving e-commerce product recommendations, search engine result recommendations, application market recommendations, music recommendations, video recommendations, etc.
  • the recommended items in various application scenarios can also be referred to as "objects" to facilitate subsequent descriptions, that is, in different recommendation scenarios, the recommended object can be an APP, or a video, or music, or a certain product (such as the presentation interface of an online shopping platform, which will display different products for presentation according to different users, which can actually be presented through the recommendation results of a recommendation model).
  • These recommendation scenarios usually involve user behavior log collection, log data preprocessing (e.g., quantization, sampling, etc.), sample set training to obtain recommendation models, and analysis and processing of objects involved in the scenarios corresponding to the training sample items (such as APP, music, etc.) according to the recommendation model.
  • the samples selected in the recommendation model training phase come from the operation behaviors of users in the mobile application market for the recommended APP.
  • the recommendation model trained in this way is applicable to the above-mentioned mobile APP application market, or can be used in the APP application market of other types of terminals to recommend terminal APPs.
  • the recommendation model will eventually calculate the recommendation probability or score of each object to be recommended.
  • the recommendation system selects the recommendation results according to certain selection rules, such as sorting by recommendation probability or score, presenting them to users through corresponding applications or terminal devices, and users operate on the objects in the recommendation results to generate user behavior logs.
  • a recommendation request is triggered.
  • the recommendation system inputs the request and its related feature information into the deployed recommendation model, and then predicts the user's click-through rate for all candidate objects. Subsequently, the candidate objects are sorted in descending order according to the predicted click-through rate, and the candidate objects are displayed in order in different positions as the recommendation results for the user.
  • the user browses the displayed items and performs user behaviors, such as browsing, clicking, and downloading. These user behaviors will be stored in the log as training data, and the parameters of the recommendation model will be updated from time to time through the offline training module to improve the recommendation effect of the model.
  • the recommendation module of the app market predicts the possibility of the user downloading each given candidate application based on the user's historical download records, user click records, the application's own characteristics, time, location and other environmental characteristics. Based on the prediction results, the app market displays them in descending order of likelihood to increase the probability of application download. Specifically, applications that are more likely to be downloaded are ranked at the front, and applications that are less likely to be downloaded are ranked at the back.
  • the user's behavior will also be stored in the log and the parameters of the prediction model will be trained and updated through the offline training module.
  • Lifelong companions can record past events of users based on system data and application data, understand the user's current intentions, predict the user's future actions or behaviors, and ultimately realize intelligent services.
  • the user's behavior data including end-side text messages, photos, email events, etc.
  • a user portrait system is built, and on the other hand, a learning and memory module based on user information filtering, association analysis, cross-domain recommendations, causal reasoning, etc. is implemented to build a user's personal knowledge graph.
  • an embodiment of the present invention provides a recommendation system architecture 200.
  • the data collection device 260 is used to collect samples.
  • a training sample can be composed of multiple feature information (or described as attribute information, such as user attributes and item attributes).
  • feature information can specifically include user feature information, object feature information, and label features.
  • User feature information is used to characterize user features, such as gender, age, occupation, hobbies, etc.
  • Object feature information is used to characterize the features of the object pushed to the user.
  • Different recommendation systems correspond to different objects, and the feature types that need to be extracted from different objects are also different.
  • the object features extracted from the training samples of the APP market can be the name (identification) of the APP, type, size, etc.
  • the object features mentioned in the training samples of e-commerce apps can be the name of the product, the category it belongs to, the price range, etc.
  • the label feature is used to indicate whether the sample is a positive example or a negative example.
  • the label feature of the sample can be obtained through the user's operation information on the recommended object.
  • the sample in which the user operates the recommended object is a positive example, and the sample in which the user does not operate the recommended object or only browses the recommended object is a negative example.
  • the label feature is 1, indicating that the sample is a positive example. If the user does not perform any operation on the recommended object, the label feature is 0, indicating that the sample is a negative example. It is a negative example.
  • the samples can be stored in the database 230. Some or all of the feature information in the samples in the database 230 can also be directly obtained from the client device 240, such as user feature information, user operation information on the object (used to determine the type identification), object feature information (such as object identification), etc.
  • the training device 220 obtains a model parameter matrix based on the sample training in the database 230 for generating the recommendation model 201. The following will describe in more detail how the training device 220 trains to obtain the model parameter matrix for generating the recommendation model 201.
  • the recommendation model 201 can be used to evaluate a large number of objects to obtain the scores of each object to be recommended. Further, a specified or preset number of objects can be recommended from the evaluation results of a large number of objects.
  • the calculation module 211 obtains the recommendation result based on the evaluation result of the recommendation model 201, and recommends it to the client device through the I/O interface 212.
  • the training device 220 can select positive and negative samples from the sample set in the database 230 and add them to the training set, and then use the recommendation model to train the samples in the training set to obtain a trained recommendation model; the implementation details of the calculation module 211 can refer to the detailed description of the method embodiment shown in Figure 5.
  • the recommendation model 201 is sent to the execution device 210, or the model parameter matrix is directly sent to the execution device 210, and the recommendation model is constructed in the execution device 210 for making recommendations for the corresponding system.
  • the recommendation model obtained based on video-related sample training can be used to recommend videos to users on video websites or APPs
  • the recommendation model obtained based on APP-related sample training can be used to recommend APPs to users in the application market.
  • the execution device 210 is configured with an I/O interface 212 for data exchange with external devices.
  • the execution device 210 can obtain user feature information, such as user identification, user identity, gender, occupation, hobbies, etc., from the client device 240 through the I/O interface 212. This part of information can also be obtained from the system database.
  • the recommendation model 201 recommends target recommendation objects to the user based on the user feature information and the feature information of the recommended object.
  • the execution device 210 can be set in a cloud server or in a user client.
  • the execution device 210 can call data, codes, etc. in the data storage system 250, and can also store output data in the data storage system 250.
  • the data storage system 250 can be set in the execution device 210, or can be set independently, or can be set in other network entities, and the number can be one or more.
  • the calculation module 211 uses the recommendation model 201 to process the user characteristic information and the characteristic information of the object to be recommended. For example, the calculation module 211 uses the recommendation model 201 to analyze and process the user characteristic information and the characteristic information of the object to be recommended, so as to obtain the score of the object to be recommended, and sort the objects to be recommended according to the scores, wherein the objects with higher rankings will be recommended to the client device 240.
  • the I/O interface 212 returns the recommendation result to the client device 240 for presentation to the user.
  • the training device 220 can generate corresponding recommendation models 201 based on different sample feature information for different goals to provide users with better results.
  • FIG2 is only a schematic diagram of a system architecture provided by an embodiment of the present invention.
  • the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation.
  • the data storage system 250 is an external memory relative to the execution device 210. In other cases, the data storage system 250 can also be placed in the execution device 210.
  • the training device 220, the execution device 210, and the client device 240 may be three different physical devices respectively. It is also possible that the training device 220 and the execution device 210 are on the same physical device or a cluster. It is also possible that the execution device 210 and the client device 240 are on the same physical device or a cluster.
  • a system architecture 300 is provided in an embodiment of the present invention.
  • the execution device 210 is implemented by one or more servers, and optionally, cooperates with other computing devices, such as data storage, routers, load balancing, etc. Scales and other equipment; the execution device 210 can be arranged at one physical site or distributed at multiple physical sites.
  • the execution device 210 can use the data in the data storage system 250, or call the program code in the data storage system 250 to implement the object recommendation function.
  • the recommendation model generates an estimated score for each object to be recommended, and then sorts them in order from high to low according to the estimated scores, and recommends the object to be recommended to the user according to the sorting results. For example, the first 10 objects in the sorting results are recommended to the user.
  • the data storage system 250 is used to receive and store the parameters of the recommendation model sent by the training device, and to store the data of the recommendation results obtained by the recommendation model. Of course, it may also include the program code (or instructions) required for the normal operation of the storage system 250.
  • the data storage system 250 can be a distributed storage cluster composed of one or more devices deployed outside the execution device 210. At this time, when the execution device 210 needs to use the data on the storage system 250, the storage system 250 can send the data required by the execution device to the execution device 210, and accordingly, the execution device 210 receives and stores (or caches) the data. Of course, the data storage system 250 can also be deployed in the execution device 210.
  • the distributed storage system can include one or more memories.
  • different memories are used to store different types of data, such as the model parameters of the recommendation model generated by the training device and the data of the recommendation results obtained by the recommendation model can be stored in two different memories respectively.
  • Each local device can represent any computing device, such as a personal computer, a computer workstation, a smart phone, a tablet computer, a smart camera, a smart car or other type of cellular phone, a media consumption device, a wearable device, a set-top box, a game console, etc.
  • the local device of each user can interact with the execution device 210 through a communication network of any communication mechanism/communication standard.
  • the communication network can be a wide area network, a local area network, a point-to-point connection, etc., or any combination thereof.
  • the execution device 210 may be implemented by a local device.
  • the local device 301 may implement the recommendation function of the execution device 210 based on the recommendation model to obtain user feature information and feedback the recommendation result to the user, or provide services to the user of the local device 302.
  • CTR Click-throughrate
  • Click probability also known as click-through rate
  • Click-through rate refers to the ratio of the number of clicks and exposures of recommended information (for example, recommended items) on a website or application. Click-through rate is usually an important indicator in the recommendation system.
  • a personalized recommendation system refers to a system that uses a machine learning algorithm to analyze the user's historical data (such as the operation information in the embodiment of the present application), and uses this to predict new requests and provide personalized recommendation results.
  • Offline training refers to a module in a personalized recommendation system that iteratively updates the recommendation model parameters according to the machine learning algorithm based on the user's historical data (such as the operation information in the embodiment of the present application) until the set requirements are met.
  • Online prediction refers to predicting the user's preference for the recommended item in the current context based on the offline trained model according to the characteristics of the user, item and context, and predicting the probability of the user selecting the recommended item.
  • FIG4A is a schematic diagram of a recommendation system provided in an embodiment of the present application.
  • a recommendation request is triggered, and the recommendation system sends the request and related information (for example, The operation information in the system is input into the recommendation model, and then the selection rate of the items in the system is predicted. Further, the items are sorted in descending order according to the predicted selection rate or a function based on the selection rate, that is, the recommendation system can display the items in different positions in order as the recommendation results for the user.
  • the user browses the items in different positions and performs user behaviors, such as browsing, selecting, and downloading.
  • the actual behavior of the user will be stored in the log as training data, and the parameters of the recommendation model will be continuously updated through the offline training module to improve the prediction effect of the model.
  • a user can trigger the recommendation system in the application market by opening the application market in a smart terminal (e.g., a mobile phone).
  • the recommendation system in the application market will predict the probability of the user downloading each recommended candidate APP based on the user's historical behavior log, such as the user's historical download records, user selection records, and the application market's own characteristics, such as time, location and other environmental feature information.
  • the recommendation system in the application market can display the candidate APPs in descending order according to the predicted probability values, thereby increasing the download probability of the candidate APPs.
  • an APP with a higher predicted user selection rate may be displayed in a front recommended position, and an APP with a lower predicted user selection rate may be displayed in a back recommended position.
  • the above-mentioned recommendation model may be a neural network model.
  • the following introduces the relevant terms and concepts of the neural network that may be involved in the embodiments of the present application.
  • a neural network may be composed of neural units, and a neural unit may refer to an operation unit that takes xs (i.e., input data) and intercept 1 as input, and the output of the operation unit may be:
  • n is a natural number greater than 1
  • Ws is the weight of xs
  • b is the bias of the neural unit.
  • f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal.
  • the output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function.
  • a neural network is a network formed by connecting multiple single neural units mentioned above, that is, the output of one neural unit can be the input of another neural unit.
  • the input of each neural unit can be connected to the local receptive field of the previous layer to extract the characteristics of the local receptive field.
  • the local receptive field can be an area composed of several neural units.
  • Deep Neural Network also known as multi-layer neural network
  • DNN Deep Neural Network
  • the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer.
  • the first layer is the input layer
  • the last layer is the output layer
  • the layers in between are all hidden layers.
  • the layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.
  • the definitions of these parameters in DNN are as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as w_24 ⁇ 3. The superscript 3 represents the layer number where the coefficient W is located, while the subscripts correspond to the output third-layer index 2 and the input second-layer index 4. In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as W_jk ⁇ L. It should be noted that there is no W parameter in the input layer. In deep neural networks, more hidden layers allow the network to better characterize the real world.
  • Training a deep neural network is the process of learning the weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (the weight matrix formed by many layers of vectors W).
  • the error back propagation (BP) algorithm can be used to correct the size of the parameters in the initial model during the training process, so that the error loss of the model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial model are updated by back propagating the error loss information, so that the error loss converges.
  • the back propagation algorithm is a back propagation movement dominated by error loss, aiming to obtain the optimal model parameters, such as the weight matrix.
  • the parameters of the machine learning model are trained through optimization methods such as gradient descent, and finally the trained model is used to complete the prediction of unknown data.
  • a system that uses machine learning algorithms to analyze and build models based on historical user data, and uses this to predict new user requests and provide personalized recommendation results.
  • Hybrid experts In a neural network, each linear layer is regarded as an expert. Multiple linear layers are run in parallel. The output of one or more experts is weighted averaged and the result is output to the next layer.
  • Computational graph A computational graph structure constructed by the operations described by the user through the deep neural network framework. It usually describes the entire deep neural network calculation process, including forward propagation, back propagation, and parameter update.
  • Memory network Convert the input into a vector internal to the network and store the vector in the memory matrix.
  • Routing A function that controls the mapping relationship between input data and a certain network module.
  • Continuous learning also known as lifelong learning, is a research direction for solving such problems. Its goal is to expand the adaptability of the model so that the model can learn knowledge of different tasks at different times without forgetting the characteristics of previous tasks.
  • Page table A data structure that can be used to record the mapping relationship between two types of data. It is usually used to convert virtual addresses into physical addresses.
  • a hierarchical page table is also a type of page table.
  • the page table is stored in a storage medium.
  • the base address of the page table also referred to as the page table base address, refers to the starting address of the physical address that stores the page table.
  • the size of the page table determines the value range of the virtual address corresponding to the page table.
  • the virtual address in the page table is the virtual address of the instance or device that uses the page table.
  • the address is used to indicate the offset of the physical address of a certain position (or a certain table entry) in the page table relative to the base address of the page table.
  • the data stored at a certain position in the page table is the physical address in the physical address space of the instance or device using this page table.
  • a page table includes multiple table entries, each of which can indicate the mapping relationship between a virtual address and a physical address. It should be understood that the table entry mentioned here is a functional description, and the specific implementation method of the table entry is not limited in this application. For example, the mapping relationship between a virtual address and a physical address may be cross-level, and the mapping relationship between a virtual address and a physical address may also be indirect.
  • the page table in this application can specifically be a multi-level page table.
  • FIG. 4B is a schematic diagram of the architecture of a transformer layer.
  • the neural network includes an embedding layer and at least one transformer layer, and the at least one transformer layer can be N transformer layers (N is an integer greater than 0), wherein each transformer layer includes an attention layer, an add&norm layer, a feed forward layer, and an add&norm layer that are adjacent in sequence.
  • the current input is embedded to obtain multiple feature vectors;
  • P input vectors are obtained from the previous layer of the transformer layer, and the first input vector among the P input vectors is taken as the center, and the intermediate vector corresponding to the first input vector is obtained based on the correlation between each input vector within the preset attention window range and the first input vector, so as to determine the P intermediate vectors corresponding to the P input vectors;
  • the P intermediate vectors are merged into Q output vectors, wherein the multiple output vectors obtained by the last transformer layer in at least one transformer layer are used as the feature representation of the current input.
  • the current input is embedded to obtain multiple feature vectors.
  • the embedding layer may be referred to as an input embedding layer.
  • the current input may be a text input, such as a paragraph of text or a sentence.
  • the text may be a Chinese text, an English text, or a text in another language.
  • the embedding layer may embed each word in the current input, and obtain a feature vector of each word.
  • the embedding layer includes an input embedding layer and a positional encoding layer.
  • each word in the current input may be subjected to word embedding processing, thereby obtaining a word embedding vector of each word.
  • the position of each word in the current input may be obtained, and then a position vector may be generated for the position of each word.
  • the position of each word may be the absolute position of each word in the current input. Taking the current input as “How many numbers should I return Huabei” as an example, the position of “how many” may be represented as the first position, the position of “number” may be represented as the second position, and so on. In some examples, the position of each word may be the relative position between each word. Still taking the current input of "repayment due on which date” as an example, the position of "how many” can be expressed as before “number”, the position of "number” can be expressed as after "how many” and before “should”, etc.
  • the position vector of each word and the corresponding word embedding vector can be combined to obtain the feature vector of each word, that is, to obtain multiple feature vectors corresponding to the current input.
  • Multiple feature vectors can be represented as an embedding matrix with a preset dimension. The number of feature vectors in the multiple feature vectors can be set to M, and the preset dimension can be H, then the multiple feature vectors can be represented as an M ⁇ H embedding matrix.
  • P input vectors are obtained from the previous layer of the first transformer layer, and the intermediate vector corresponding to the first input vector is obtained based on the correlation between each input vector within the preset attention window range and the first input vector, so as to determine the P intermediate vectors corresponding to the P input vectors.
  • the attention layer can also be called a multi-head attention layer.
  • the attention layer can be a fixed window multi-head attention layer.
  • the first transformer layer may be the next layer of the embedding layer, and the P input vectors are The multiple feature vectors obtained by the embedding layer.
  • at least one transformer layer in the neural network provided in the embodiments of this specification also includes a second transformer layer.
  • the second transformer layer is the previous layer of the first self-attention, and the P input vectors are the P output vectors output by the second transformer layer.
  • the multiple output vectors obtained through the above steps can be used as a feature representation of the current input.
  • the feature representation is a feature representation of the current input suitable for computer processing.
  • the attention mechanism imitates the internal process of biological observation behavior, that is, a mechanism that aligns internal experience and external sensations to increase the observation precision of some areas, and can use limited attention resources to quickly filter out high-value information from a large amount of information.
  • the attention mechanism can quickly extract important features of sparse data, and is therefore widely used in natural language processing tasks, especially machine translation.
  • the self-attention mechanism is an improvement on the attention mechanism, which reduces dependence on external information and is better at capturing the internal correlation of data or features.
  • the essential idea of the attention mechanism can be rewritten as the following formula:
  • Lx
  • represents the length of Source.
  • the formula means that the elements in Source are imagined to be composed of a series of data pairs. At this time, given a certain element Query in the target Target, by calculating the similarity or correlation between Query and each Key, the weight coefficient of the Value corresponding to each Key is obtained, and then the Value is weighted and summed to obtain the final Attention value. Therefore, the Attention mechanism is essentially a weighted sum of the Value values of the elements in Source, and Query and Key are used to calculate the weight coefficient of the corresponding Value.
  • Attention can be understood as selectively filtering out a small amount of important information from a large amount of information and focusing on these important information, ignoring most of the unimportant information.
  • the focusing process is reflected in the calculation of the weight coefficient.
  • the self-attention mechanism can be understood as internal Attention (intra attention).
  • the Attention mechanism occurs between the Query element of the Target and all the elements in the Source.
  • the specific calculation process is the same, but the calculation object has changed.
  • Another problem with this core issue is how to design and train such a costly model to fully realize its value, and at the beginning of the design, it is necessary to prepare for possible unknown usage scenarios in the future, because such a costly model cannot be retrained over and over again, so there needs to be some form that can save the results of previous training and be able to prepare for possible usage scenarios in the future.
  • a large-scale model can be divided into multiple network units. Corresponding network units are set for different input samples (such as different word vectors). When a certain input sample is used for model training, only the network unit corresponding to the input sample among the multiple network units is updated, and the updated network unit will be stored so that it can be called at the next update.
  • the present application provides a data processing method.
  • FIG. 5 is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application.
  • a data processing method provided in an embodiment of the present application includes:
  • the target mapping relationship determine one or more target network units corresponding to the target word vector token and the storage address of the one or more target network units, and the storage space corresponding to the storage address is located in the storage space outside the computing unit.
  • the execution subject of step 501 may be a terminal device, and the terminal device may be a portable mobile device, such as but not limited to a mobile or portable computing device (such as a smart phone), a personal computer, a server computer, a handheld device (such as a tablet) or a laptop device, a multi-processor system, a game console or controller, a microprocessor-based system, a set-top box, a programmable consumer electronic product, a mobile phone, a mobile computing and/or communication device with a wearable or accessory form factor (such as a watch, glasses, a headset or earplugs), a network PC, a minicomputer, a mainframe computer, a distributed computing environment including any of the above systems or devices, and the like.
  • a mobile or portable computing device such as a smart phone
  • a personal computer such as a server computer
  • a handheld device such as a tablet
  • a laptop device such as a laptop device
  • a multi-processor system such as a game
  • the execution entity of step 501 may be a server on the cloud side.
  • the target network unit is a feed forward network FFN, and the target network unit may also be referred to as an expert network in the embodiment of the present application.
  • a mapping relationship between different training samples (word vector tokens) and target network units can be pre-constructed.
  • word vector tokens word vector tokens
  • target network units or it can be called a multi-value mapping table or a multi-level mapping table
  • the network structure at the location of the target network unit in the large-scale network can be set to the network unit or a combination of network units indicated in the mapping relationship.
  • the target mapping relationship may include a first target mapping relationship and a second target mapping relationship
  • the first target mapping relationship may indicate a mapping relationship between a word vector and a network unit, specifically a mapping relationship between a word vector and an identification ID corresponding to the network unit.
  • Identification used to distinguish one or a thing from other similar or different things. For example, a node identifier, a network identifier, a network card identifier.
  • the identifier can be a name, a number, or a distinguishing feature, such as a type identifier.
  • the present application does not limit the implementation of various identifiers, as long as a distinction can be made.
  • mapping relationship between training samples (word vector tokens) and network units is constructed by hashing. Since one training sample in the hash can only correspond to one unique network unit, and since there is a numerical range limit in the hash, as the number of training samples increases, a large number of different training samples may correspond to the same network unit, which affects the accuracy of the trained model.
  • the mapping relationship between training samples (word vector tokens) and network units is recorded in a mapping table, so that one training sample can correspond to multiple network units, and since there is no numerical range limit, a large number of different training samples will not correspond to the same network unit, thereby increasing the accuracy of the trained model.
  • a large-scale network (such as Pangu alpha or FFN in Transformer) can be replaced with the storage unit in Figure 6, that is, several experts arranged in parallel.
  • the grouping of these experts is determined by a multi-value mapping table.
  • Each multi-value mapping table is composed of many key-value pairs.
  • the words (tokens) in the vocabulary constitute the key of the multi-value mapping table, and the value is the ID number of the expert, such as E1 to E11 in the figure.
  • the control module can dynamically extract the computing units that need to be calculated from the storage unit according to the data of the data unit for efficient calculation.
  • the grouping is determined by the user when constructing the multi-value mapping table.
  • a multi-injection mapping table as shown in Figure 7 can be constructed.
  • the user first determines the number of groups G that need to be modeled, as well as the number of experts K_g initialized for each group.
  • For the tokens in the vocabulary, which group or groups they belong to is determined by the user.
  • the user can group the tokens according to the language to which they belong, with Chinese as one expert group and English as another expert group. Some tokens belong to two expert groups, such as some Arabic numerals.
  • the number of experts in each group is also fixed.
  • the tokens belonging to this expert group can be assigned to the experts through a certain function, such as randomly or sequentially.
  • the computing unit is a graphics processing unit GPU, a tensor processing unit TPU or a neural network processor NPU.
  • the storage space corresponding to the storage address is located in a memory, a network storage, or a hard disk.
  • the target mapping relationship includes a first target mapping relationship
  • the first target mapping relationship indicates multiple word vectors and one or more network units corresponding to each word vector
  • the first target mapping relationship is specifically a mapping table.
  • the target mapping relationship may further include a third target mapping relationship, and the third target mapping relationship indicates the storage location of each network element.
  • the storage location may be represented by a physical address or a virtual address corresponding to the storage space, and the corresponding physical address may be uniquely determined based on the virtual address, for example, the address may include a starting address and an offset.
  • the target network unit in the large-scale model is stored in a storage location outside the computing unit, when the current training sample is the corresponding word vector, the corresponding one or more target network units are extracted from the storage location outside the computing unit. Since the storage space of the storage location outside the computing unit can be set larger, the size of the large-scale model itself can be increased through storage and computing separation, and the scalability and flexibility of the large-scale model can be increased.
  • the above target mapping relationship can be modified by a user.
  • modification information from the user regarding a second target mapping relationship may also be received, wherein the second target mapping relationship includes multiple word vectors and a network unit corresponding to each word vector; the second target mapping relationship is modified according to the modification information to obtain the target mapping relationship.
  • the modification information can be used to modify the network unit corresponding to a word vector in the second target mapping relationship, or to modify the correspondence between the word vector and the network unit.
  • the modification information is used to indicate at least one of the following: deletion, replacement or addition of a network unit corresponding to at least one word vector in the second target mapping relationship; deletion, replacement or addition of a mapping relationship included in the second target mapping relationship, wherein the mapping relationship is a word vector and a network unit corresponding to the word vector.
  • system can also modify the mapping relationship based on the model training situation.
  • the structure of the neural network can be changed by adding network units so that the training loss can continue to decrease), the network units corresponding to the target word vector in the second target mapping relationship can be added to obtain the target mapping relationship.
  • the present embodiment can support the expansion and deletion of the capacity of the memory network, and at the same time achieve the effect of continuous learning.
  • Continuous learning refers to the technology that the model can continue to learn new data after learning data for a period of time, which can avoid the knowledge learned previously from being forgotten, and can learn new knowledge at the same time.
  • Step 1 Training reads whether the mapping table is modified from the configuration file. If there is a modification, the multi-value mapping table and the corresponding storage unit are modified according to the configuration.
  • This configuration is very flexible. It can be an expansion of the same expert group, such as the expansion of expert group E4 in the figure, or it can be an expansion of a new expert group, such as the expansion of expert group 3 in the figure. Then continue training.
  • Step 2 Read the amplification threshold K in the configuration file, and for each expert group's loss, always record the minimum loss value. If the minimum value has not been updated for K consecutive steps, it is considered that the model loss has no longer decreased, and go to step 3. Otherwise, continue training.
  • Step 3 After the conditions of step 2 are met, modify the multi-value mapping table for the expert group corresponding to the loss that does not decrease. Assuming that the original expert group is M experts, add a new mapping expert to the experts mapped to 1/M tokens in the multi-value mapping table according to a certain rule, as shown in E4 in the figure. This rule can be the most frequent 1/M tokens, or randomly select 1/M tokens.
  • Step 4 The framework adjusts the computational graph in real time, allocates new storage space to the newly added expert E4, and continues training.
  • the memory module of the model can be scaled to expand and tailor the model capacity for different scenarios.
  • the one or more target network units from the storage space corresponding to the storage address; the one or more target network units are used to construct a neural network.
  • the one or more target network units can be obtained from the storage space corresponding to the storage address, and the one or more target network units can be used to construct a neural network. Specifically, one or more target network units can be used to construct a network structure corresponding to the position of the target network unit.
  • FIG. 8 A schematic diagram of the specific process can be shown in Figure 8 below, which mainly consists of the following steps:
  • Step 1 When an iteration of training begins, the control module reads the data of this iteration.
  • Step 2 Based on the data read in the previous step, use the data as the key in the multi-value mapping table to find the corresponding expert number.
  • Step 3 There are two steps. First, find the memory address of the corresponding expert according to the expert number found in the previous step. Then 3.2, extract the experts to be used or freeze the unused experts according to the found memory address. This extraction can be to build a calculation subgraph in a new memory space and copy the corresponding experts in the storage unit to the new calculation space, or to use a virtual memory mapping in the storage unit to manage the corresponding experts in the storage unit as a calculation unit. This freezing will propagate the freezing operation from the calculation graph to the corresponding reverse calculation node and optimizer update node, ensuring that the experts who do not need to be calculated in this round do not need to participate in the calculation of the forward, reverse and optimizer updates.
  • the computing unit executes a training process corresponding to the neural network.
  • the training process corresponding to the target neural network is executed by the computing unit to obtain an updated target neural network, and the updated target neural network includes the updated one or more target network units. According to the updated one or more target network units, the data in the storage space corresponding to the storage address is updated for the next call.
  • an optional implementation step of the embodiment of the present application may include:
  • Step 4 Use the computing unit constructed in the previous step to perform actual calculations on the data read in step 1 and the corresponding experts, forward-propagate the loss, perform reverse calculations, and update the expert parameters with the optimizer.
  • Step 5 Synchronize the updated expert parameters in the computing unit with the corresponding expert parameters in the storage unit.
  • the idea behind the above steps is to find out the sparse expert memory units, that is, the experts in the storage units, through memory management, and ensure that only these activated experts are calculated.
  • the rest that do not need to be calculated do not participate in any forward, backward, or optimizer update calculations, ensuring that the sparse memory network has no redundancy in calculations, thereby improving training efficiency.
  • the target mapping relationship includes multiple word units and a network unit corresponding to each word unit.
  • the network units corresponding to some word units can also be determined from the multiple word units included in the target mapping relationship based on the neural network after convergence.
  • the network units corresponding to some word units in the neural network after convergence are used to construct a target neural network; the target neural network is used to perform model inference.
  • the above process can be called sub-model extraction, and an exemplary process can be shown in FIG. 10 .
  • the embodiment of the present application proposes a new type of scalable memory network design and its efficient training algorithm. It ensures that while a large model composed of such network modules can be efficiently trained, the model can obtain continuous learning capabilities through the expansion and contraction of the memory module, ensuring that the model is always in the latest knowledge state.
  • the system architecture is shown in Figure 11 below:
  • the first is the multi-value mapping table.
  • This module is the feasible data structure basis of this patent. Unlike the hash mentioned in the above related work, mapping is a directly stored key-value pair relationship. It does not need to be mapped to a fixed index range through a hash function, so there is no collision problem. This determines that the relationship constructed with the mapping data structure will not lose key information.
  • the multi-value mapping used here is to build a mapping pair of a key value and a set. The set can contain any number of elements, which ensures that our mapping relationship is not just a single one.
  • the multi-value mapping table in this patent supports multiple operations, such as search, insertion, deletion and other modifications. These operations cooperate with the control module to be described below to realize the training algorithm and lifelong learning algorithm described in our patent.
  • the second is the control module.
  • the control module is shown as the dotted control module in the figure below.
  • the control module is the core of this system and has two main functions:
  • One is a function designed to complete lifelong learning capabilities. After the control module obtains information from the loss or a certain metric function, if it determines that the number of memory networks needs to be increased, the algorithm enters the "yes" branch, and the storage control unit first modifies the multi-value mapping table, adds or deletes the key-value pairs in the mapping, and then the storage control unit opens up or releases the corresponding memory space in the storage subgraph part.
  • the algorithm will go to the "no" branch.
  • the routing of the control module can read the data of the current data unit, query the mapping relationship in the multi-value mapping table, and know the number of the memory network that needs to be calculated this time.
  • the calculation control module will extract the subgraph that needs to be calculated in some way, which can be pulled, or a new subgraph can be built, or the uncalculated part can be frozen locally where the subgraph is stored to ensure that only the part that needs to be calculated is calculated. And this operation will be propagated to all relevant calculation parts of the calculation graph. In large-scale distributed scenarios, the corresponding gradient transmission will not be performed, thereby greatly reducing the amount of calculation and communication of the entire model.
  • the third is the memory network module. It is the storage unit and computing unit in the figure.
  • the memory module is composed of linear networks, usually more than one linear network.
  • Each linear network has a number, such as A, B, C, D in the figure, which is used to distinguish different linear networks. This number is also the value element in the key-value pair in the multi-value mapping table.
  • the control device can find the address of the corresponding memory network through this value, and extract, copy, delete, add and other operations on the corresponding network.
  • Each network memorizes the current layer features corresponding to the current state training entity.
  • the fourth is the data unit, which can be training data or some encoded intermediate results.
  • a data processing device 1200 provided by an embodiment of the present application includes:
  • the processing module 1201 is used to determine one or more target network units corresponding to the target word vector token and the storage addresses of the one or more target network units according to the target mapping relationship, and the storage space corresponding to the storage address is located in the storage space outside the computing unit;
  • the one or more target network units are used to construct a neural network
  • processing module 1201 For the specific description of the processing module 1201 , reference may be made to the introduction of step 501 and step 502 in the above embodiment, which will not be repeated here.
  • the model training module 1202 is used to execute the training process corresponding to the neural network through the computing unit according to the target word vector.
  • model training module 1202 for the specific description of the model training module 1202, please refer to the introduction of step 503 in the above embodiment, which will not be repeated here.
  • the target network unit is a feed forward network FFN.
  • the computing unit is a graphics processing unit GPU, a tensor processing unit TPU, or a neural network processor NPU.
  • the storage space corresponding to the storage address is located in a memory, a network storage, or a hard disk.
  • the target mapping relationship includes a first target mapping relationship
  • the first target mapping relationship indicates multiple word vectors and one or more network units corresponding to each word vector
  • the first target mapping relationship is specifically a mapping table.
  • the training process corresponding to the target neural network is performed by the computing unit to obtain an updated target neural network
  • the updated target neural network includes the updated one or more target network units
  • the processing module is further used to:
  • data in the storage space corresponding to the storage address is updated.
  • the processing module before determining, according to the target mapping relationship, one or more target network units corresponding to the target word vector and the storage addresses of the one or more target network units, the processing module is further used to:
  • the second target mapping relationship includes a plurality of word vectors and a network unit corresponding to each word vector;
  • the second target mapping relationship is modified according to the modification information to obtain the target mapping relationship.
  • the modification information is used to indicate at least one of the following:
  • mapping relationship included in the second target mapping relationship, wherein the mapping relationship is a word vector and a network unit corresponding to the word vector.
  • the processing module before determining, according to the target mapping relationship, one or more target network units corresponding to the target word vector and the storage addresses of the one or more target network units, the processing module is further used to:
  • the degree of decrease of the training loss is low.
  • the network unit corresponding to the target word vector in the second target mapping relationship is increased to obtain the target mapping relationship.
  • the target mapping relationship includes multiple word units and a network unit corresponding to each word unit, and the processing module is further used to:
  • network units corresponding to some word units are determined from multiple word units included in the target mapping relationship, and the network units corresponding to the some word units in the neural network after convergence are used to construct a target neural network; the target neural network is used to perform model inference.
  • FIG. 13 is a structural schematic diagram of an execution device provided in an embodiment of the present application.
  • the execution device 1300 can be specifically expressed as a mobile phone, a tablet, a laptop computer, an intelligent wearable device, a server, etc., which is not limited here.
  • the execution device 1300 implements the function of the image processing method in the corresponding embodiment of Figure 10.
  • the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303 and a memory 1304 (wherein the number of processors 1303 in the execution device 1300 can be one or more), wherein the processor 1303 may include an application processor 13031 and a communication processor 13032.
  • the receiver 1301, the transmitter 1302, the processor 1303 and the memory 1304 may be connected via a bus or other means.
  • the memory 1304 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1303. A portion of the memory 1304 may also include a non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the memory 1304 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
  • the processor 1303 controls the operation of the execution device.
  • the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc.
  • the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc.
  • various buses are referred to as bus systems in the figure.
  • the method disclosed in the above embodiment of the present application can be applied to the processor 1303, or implemented by the processor 1303.
  • the processor 1303 can be an integrated circuit chip with signal processing capabilities.
  • each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1303.
  • the above processor 1303 can be a general-purpose processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and a vision processor (vision processing unit, VPU), a tensor processor (tensor processing unit, TPU) and other processors suitable for AI computing, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • the processor 1303 can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
  • the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
  • the steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc.
  • the storage medium is located in the memory 1304, and the processor 1303 reads the information in the memory 1304, and completes the steps 501 to 503 in the above embodiment in combination with its hardware.
  • the receiver 1301 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device.
  • the transmitter 1302 can be used to output digital or character information through the first interface;
  • the transmitter 1302 may also be used to send instructions to the disk group through the first interface to modify data in the disk group; the transmitter 1302 may also include a display device such as a display screen.
  • the present application also provides a training device, please refer to FIG. 14, which is a structural diagram of the training device provided by the present application.
  • the training device 1400 can be the data processing device introduced in the above embodiment.
  • the training device 1400 is implemented by one or more servers.
  • the training device 1400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1414 (for example, one or more processors) and memory 1432, one or more storage media 1430 (for example, one or more mass storage devices) storing application programs 1442 or data 1444.
  • the memory 1432 and the storage medium 1430 can be short-term storage or permanent storage.
  • the program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processor 1414 can be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the training device 1400.
  • the training device 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458; or, one or more operating systems 1441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
  • the embodiment of the present application also provides a computer program product including computer-readable instructions, which, when executed on a computer, enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
  • a computer-readable storage medium is also provided in an embodiment of the present application, which stores a program for signal processing.
  • the computer-readable storage medium When the computer-readable storage medium is run on a computer, it enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
  • the execution device, training device or terminal device provided in the embodiments of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input/output interface, a pin or a circuit, etc.
  • the processing unit may execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the model training method described in the above embodiment, or so that the chip in the training device executes the steps related to model training in the above embodiment.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc.
  • the storage unit may also be a storage unit located outside the chip in the wireless access device end, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
  • ROM read-only memory
  • RAM random access memory
  • FIG. 15 is a schematic diagram of a structure of a chip provided in an embodiment of the present application.
  • the chip can be expressed as a neural network processor NPU 1500.
  • NPU 1500 is mounted on the host CPU (Host CPU) as a coprocessor, and tasks are assigned by the Host CPU.
  • the core part of the NPU is the operation circuit 1503, which is controlled by the controller 1504 to extract matrix data from the memory and perform multiplication operations.
  • the operation circuit 1503 includes multiple processing units (Process Engine, PE) inside.
  • the operation circuit 1503 is a two-dimensional systolic array.
  • the operation circuit 1503 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition.
  • the operation circuit 1503 is a general-purpose matrix processor.
  • the operation circuit takes the corresponding data of matrix B from the weight memory 1502 and caches it on each PE in the operation circuit.
  • the matrix A data is taken to perform matrix operations with the matrix B, and the partial results or final results of the obtained matrix are stored in the accumulator 1508.
  • Unified memory 1506 is used to store input data and output data. Weight data is directly transferred to weight memory 1502 through Direct Memory Access Controller (DMAC) 1505. Input data is also transferred to unified memory 1506 through DMAC.
  • DMAC Direct Memory Access Controller
  • BIU stands for Bus Interface Unit, that is, the bus interface unit 1510, which is used for the interaction between AXI bus and DMAC and instruction fetch buffer (IFB) 1509.
  • IOB instruction fetch buffer
  • the bus interface unit 1510 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 1509 to obtain instructions from the external memory, and is also used for the storage unit access controller 1505 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
  • BIU Bus Interface Unit
  • DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1506 or to transfer weight data to the weight memory 1502 or to transfer input data to the input memory 1501.
  • the vector calculation unit 1507 includes multiple operation processing units, which further process the output of the operation circuit when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional/fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of feature planes, etc.
  • the vector calculation unit 1507 can store the processed output vector to the unified memory 1506.
  • the vector calculation unit 1507 can apply a linear function; or a nonlinear function to the output of the operation circuit 1503, such as linear interpolation of the feature plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value.
  • the vector calculation unit 1507 generates a normalized value, a pixel-level summed value, or both.
  • the processed output vector can be used as an activation input to the operation circuit 1503, for example, for use in a subsequent layer in a neural network.
  • An instruction fetch buffer 1509 connected to the controller 1504 is used to store instructions used by the controller 1504;
  • Unified memory 1506, input memory 1501, weight memory 1502 and instruction fetch memory 1509 are all on-chip memories. External memories are private to the NPU hardware architecture.
  • the processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
  • the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
  • the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
  • the present application can be implemented by means of software plus necessary general-purpose hardware.
  • it can also be implemented by special-purpose hardware including special-purpose integrated circuits, special-purpose CPUs, special-purpose memories, special-purpose components, etc.
  • special-purpose hardware including special-purpose integrated circuits, special-purpose CPUs, special-purpose memories, special-purpose components, etc.
  • all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits.
  • software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or in other words, an improvement over the prior art.
  • the contributed part may be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions for enabling a computer device (which may be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in the various embodiments of the present application.
  • a computer device which may be a personal computer, training equipment, or network equipment, etc.
  • all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof.
  • all or part of the embodiments may be implemented in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from one website, computer, training equipment, or data center to another website, computer, training equipment, or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
  • wired e.g., coaxial cable, optical fiber, digital subscriber line (DSL)
  • wireless e.g., infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, data center, etc. that includes one or more available media integrated.
  • the available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
  • the image classification method provided in the embodiment of the present application can be applied to image retrieval, album management, safe city, human-computer interaction and other scenes that require image classification or image recognition.
  • the image in the embodiment of the present application can be a static image (or a static picture) or a dynamic image (or a dynamic picture).
  • the image in the present application can be a video or a dynamic picture, or the image in the present application can also be a static picture or a photo.
  • the present application will uniformly refer to static images or dynamic images as images in the following embodiments.
  • the image classification method of the embodiment of the present application can be specifically applied to album classification and photo recognition scenarios. These two scenarios are introduced in detail below.
  • the image classification method of the embodiment of the present application can facilitate users to classify and manage different object categories, thereby facilitating users' searches, saving users' management time, and improving the efficiency of album management.
  • the neural network provided by the present application can be used to first extract the image features of the pictures in the album, and then classify the pictures in the album according to the extracted image features to obtain the classification results of the pictures. Next, the pictures in the album are classified according to the classification results of the pictures to obtain an album arranged according to the picture categories.
  • pictures belonging to the same category can be arranged in one row or one row. For example, in the final album, the pictures in the first row are all airplanes, and the pictures in the second row are all cars.
  • Photographing and identifying objects
  • users can use the image classification method of the embodiment of the present application to process the photos taken, and can automatically identify the category of the photographed object. For example, it can automatically identify whether the photographed object is a flower, an animal, etc. Further, the image classification method of the embodiment of the present application can be used to identify the object obtained by the photo and identify the category to which the object belongs. For example, if the photo taken by the user includes a shared bicycle, the image classification method of the embodiment of the present application can be used to identify the category to which the object belongs. It can identify the shared bicycle and recognize that the object belongs to a bicycle. Furthermore, it can also display relevant information about the bicycle.
  • album classification and photo object recognition introduced above are only two specific scenarios in which the image classification method of the embodiment of the present application is applied.
  • the image classification method of the embodiment of the present application is not limited to the above two scenarios when applied.
  • the image classification method of the embodiment of the present application can be applied to any scenario that requires image classification or image recognition.
  • a new neural network model is used in the image classification method in the embodiment of the present application, and the model can also be similarly applied to other fields using neural networks, such as face recognition, speech recognition, target detection, machine translation, and semantic segmentation.
  • the embodiments of the present application involve a large number of neural network-related applications.
  • the relevant terms and concepts of the neural network that may be involved in the embodiments of the present application are first introduced below.
  • a neural network may be composed of neural units.
  • a neural unit may refer to an operation unit that takes x s and intercept 1 as input.
  • the output of the operation unit may be as shown in formula (1-1):
  • n is a natural number greater than 1
  • Ws is the weight of xs
  • b is the bias of the neural unit.
  • f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal.
  • the output signal of the activation function can be used as the input of the next convolution layer, and the activation function can be a sigmoid function.
  • a neural network is a network formed by connecting multiple single neural units mentioned above, that is, the output of one neural unit can be the input of another neural unit.
  • the input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field.
  • the local receptive field can be an area composed of several neural units.
  • a deep neural network also known as a multi-layer neural network, can be understood as a neural network with multiple hidden layers. According to the position of different layers, DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.
  • DNN looks complicated, the work of each layer is not complicated. In simple terms, it can be expressed as the following linear relationship: in, is the input vector, is the output vector, is the offset vector, W is the weight matrix (also called coefficient), and ⁇ () is the activation function.
  • Each layer is just an input vector After such a simple operation, the output vector Since DNN has many layers, the coefficient W and the offset vector The number of these parameters is also relatively large.
  • DNN The definitions of these parameters in DNN are as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.
  • the coefficients from the kth neuron in the L-1th layer to the jth neuron in the Lth layer are defined as
  • the input layer does not have a W parameter.
  • W weight matrix
  • Convolutional neural network is a deep neural network with a convolutional structure.
  • Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer, which can be regarded as a filter.
  • Convolutional layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal.
  • a neuron can only be connected to some neurons in the adjacent layers.
  • a convolutional layer usually contains several feature planes, each of which can be composed of some rectangularly arranged neural units.
  • the neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way to extract image information is independent of position.
  • the convolution kernel can be initialized in the form of a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network.
  • the direct benefit of shared weights is to reduce the connection between the layers of the convolutional neural network, while reducing the risk of overfitting.
  • Recurrent neural networks are used to process sequence data.
  • the layers are fully connected from the input layer to the hidden layer and then to the output layer, while the nodes within each layer are disconnected.
  • RNN Recurrent neural network
  • this common neural network has solved many difficult problems, it is still powerless to solve many problems. For example, if you want to predict the next word in a sentence, you generally need to use the previous word, because the previous and next words in a sentence are not independent. The reason why RNN is called a recurrent neural network is that the current output of a sequence is also related to the previous output.
  • RNN can process sequence data of any length.
  • the training of RNN is the same as the training of traditional CNN or DNN.
  • Neural networks can use the back propagation (BP) algorithm to correct the initial
  • BP back propagation
  • the size of the parameters in the neural network model makes the reconstruction error loss of the neural network model smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial neural network model are updated by back-propagating the error loss information, so that the error loss converges.
  • the back-propagation algorithm is a back-propagation movement dominated by error loss, which aims to obtain the optimal parameters of the neural network model, such as the weight matrix.
  • the pixel value of an image can be a red, green, and blue (RGB) color value, and the pixel value can be a long integer representing the color.
  • the pixel value is 256*Red+100*Green+76Blue, where Blue represents the blue component, Green represents the green component, and Red represents the red component. In each color component, the smaller the value, the lower the brightness, and the larger the value, the higher the brightness.
  • the pixel value can be a grayscale value.
  • the embodiment of the present application provides a system architecture 100.
  • the data acquisition device 160 is used to collect training data.
  • the training data may include training images and classification results corresponding to the training images, wherein the classification results of the training images may be manually pre-labeled results.
  • the data collection device 160 After collecting the training data, the data collection device 160 stores the training data in the database 130 , and the training device 120 obtains the target model/rule 101 through training based on the training data maintained in the database 130 .
  • the training device 120 processes the input original image and compares the output image with the original image until the difference between the image output by the training device 120 and the original image is less than a certain threshold, thereby completing the training of the target model/rule 101.
  • the above-mentioned target model/rule 101 can be used to implement the image classification method of the embodiment of the present application, that is, the image to be processed is input into the target model/rule 101 after relevant pre-processing, and the classification result of the image can be obtained.
  • the target model/rule 101 in the embodiment of the present application can specifically be a neural network.
  • the training data maintained in the database 130 does not necessarily all come from the collection of the data acquisition device 160, and may also be received from other devices.
  • the training device 120 does not necessarily train the target model/rule 101 completely based on the training data maintained by the database 130, and it is also possible to obtain training data from the cloud or other places for model training.
  • the above description should not be used as a limitation on the embodiments of the present application.
  • the target model/rule 101 obtained by training the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG. 16 .
  • the execution device 110 can be a terminal, such as a mobile terminal, a tablet computer, a laptop computer, an augmented reality (AR)/virtual reality (VR), a vehicle terminal, etc., and can also be a server or a cloud device, etc.
  • the execution device 110 is configured with an input/output (I/O) interface 112 for data interaction with an external device.
  • the user can input data to the I/O interface 112 through the client device 140.
  • the input data in the embodiment of the present application may include: an image to be processed input by the client device.
  • Preprocessing module 113 and preprocessing module 114 are used to perform preprocessing according to the input data (such as the image to be processed) received by I/O interface 112.
  • preprocessing module 113 and preprocessing module 114 may be omitted (or only one of the preprocessing modules may be present), and the computing module 111 may be used directly to process the input data.
  • the execution device 110 When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculations and other related processing, the execution device 110 can call the data, code, etc. in the data storage system 150 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 150.
  • the I/O interface 112 returns the processing result, such as the classification result of the image to be processed obtained above, to the client device 140 to provide it to the user.
  • the training device 120 can be targeted at different goals or different tasks based on different training
  • the data generates a corresponding target model/rule 101, which can be used to achieve the above-mentioned target or complete the above-mentioned task, thereby providing the user with the desired result.
  • the user can manually give input data, and the manual giving can be operated through the interface provided by the I/O interface 112.
  • the client device 140 can automatically send input data to the I/O interface 112. If the client device 140 is required to automatically send input data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 140.
  • the user can view the results output by the execution device 110 on the client device 140, and the specific presentation form can be a specific method such as display, sound, action, etc.
  • the client device 140 can also be used as a data acquisition terminal to collect the input data of the input I/O interface 112 and the output results of the output I/O interface 112 as shown in the figure as new sample data, and store them in the database 130.
  • the I/O interface 112 directly stores the input data of the input I/O interface 112 and the output results of the output I/O interface 112 as new sample data in the database 130.
  • Figure 16 is only a schematic diagram of a system architecture provided in an embodiment of the present application.
  • the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation.
  • the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 can also be placed in the execution device 110.
  • the target model/rule 101 is obtained through training with the training device 120.
  • the target model/rule 101 in the embodiment of the present application may be a neural network in the present application.
  • the neural network provided in the embodiment of the present application may be a CNN, a deep convolutional neural network (DCNN), a recurrent neural network (RNNS), and the like.
  • CNN is a very common neural network
  • convolutional neural network is a deep neural network with a convolution structure and a deep learning architecture.
  • Deep learning architecture refers to multiple levels of learning at different abstract levels through machine learning algorithms.
  • CNN is a feed-forward artificial neural network in which each neuron can respond to the image input into it.
  • a convolutional neural network (CNN) 200 may include an input layer 210, a convolutional layer/pooling layer 220 (wherein the pooling layer is optional), and a neural network layer 230.
  • CNN convolutional neural network
  • the convolution layer/pooling layer 220 may include layers 221-226, for example: in one implementation, layer 221 is a convolution layer, layer 222 is a pooling layer, layer 223 is a convolution layer, layer 224 is a pooling layer, layer 225 is a convolution layer, and layer 226 is a pooling layer; in another implementation, layers 221 and 222 are convolution layers, layer 223 is a pooling layer, layers 224 and 225 are convolution layers, and layer 226 is a pooling layer. That is, the output of a convolution layer can be used as the input of a subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
  • the convolution layer 221 may include many convolution operators, which are also called kernels. Their role in image processing is equivalent to a filter that extracts specific information from the input image matrix.
  • the convolution operator can essentially be a weight matrix, which is usually predefined. In the process of performing convolution operations on the image, the weight matrix is usually processed one pixel by one pixel (or two pixels by two pixels... depending on the value of the stride) along the horizontal direction on the input image, thereby completing the work of extracting specific features from the image.
  • the weight matrix is Small should be related to the size of the image. It should be noted that the depth dimension of the weight matrix is the same as the depth dimension of the input image. During the convolution operation, the weight matrix will extend to the entire depth of the input image.
  • convolution with a single weight matrix will produce a convolution output with a single depth dimension, but in most cases, a single weight matrix is not used, but multiple weight matrices of the same size (row ⁇ column) are applied, that is, multiple isotype matrices.
  • the output of each weight matrix is stacked to form the depth dimension of the convolution image, and the dimension here can be understood as being determined by the "multiple" mentioned above.
  • Different weight matrices can be used to extract different features in the image, for example, one weight matrix is used to extract image edge information, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to blur unwanted noise in the image.
  • the multiple weight matrices have the same size (row ⁇ column), and the feature maps extracted by the multiple weight matrices of the same size are also the same size. The extracted multiple feature maps of the same size are then merged to form the output of the convolution operation.
  • weight values in these weight matrices need to be obtained through a lot of training in practical applications.
  • the weight matrices formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions.
  • the initial convolutional layer (for example, 221) often extracts more general features, which can also be called low-level features.
  • the features extracted by the later convolutional layers (for example, 226) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
  • a convolution layer may be followed by a pooling layer, or multiple convolution layers may be followed by one or more pooling layers.
  • the pooling layer may include an average pooling operator and/or a maximum pooling operator to sample the input image to obtain an image of smaller size.
  • the average pooling operator may calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling.
  • the maximum pooling operator may take the pixel with the largest value in the range within a specific range as the result of maximum pooling.
  • the operator in the pooling layer should also be related to the image size.
  • the size of the image output after processing by the pooling layer may be smaller than the size of the image input to the pooling layer.
  • Each pixel in the image output by the pooling layer represents the average value or maximum value of the corresponding sub-region of the image input to the pooling layer.
  • the convolution neural network 200 After being processed by the convolution layer/pooling layer 220, the convolution neural network 200 is not sufficient to output the required output information. Because as mentioned above, the convolution layer/pooling layer 220 will only extract features and reduce the parameters brought by the input image. However, in order to generate the final output information (the required class information or other related information), the convolution neural network 200 needs to use the neural network layer 230 to generate one or a group of outputs of the required number of classes. Therefore, the neural network layer 230 may include multiple hidden layers (231, 232 to 23n as shown in Figure 17) and an output layer 240. The parameters contained in the multiple hidden layers can be pre-trained according to the relevant training data of the specific task type. For example, the task type may include image recognition, image classification, image super-resolution reconstruction, etc.
  • the output layer 240 After the multiple hidden layers in the neural network layer 230, that is, the last layer of the entire convolutional neural network 200 is the output layer 240, which has a loss function similar to the classification cross entropy, specifically used to calculate the prediction error.
  • the forward propagation of the entire convolutional neural network 200 (the propagation from 210 to 240 in FIG. 17 is the forward propagation) is completed, the back propagation (the propagation from 240 to 210 in FIG. 17 is the back propagation) will start to update the aforementioned layers.
  • the weight values and bias are used to reduce the loss of the convolutional neural network 200 and the error between the result output by the convolutional neural network 200 through the output layer and the ideal result.
  • the convolutional neural network 200 shown in FIG. 17 is only an example of a convolutional neural network. In specific applications, the convolutional neural network may also exist in the form of other network models.
  • the convolutional neural network 200 shown in FIG17 can be used to process the image to be processed to obtain the classification result of the image to be processed.
  • the image to be processed is processed by the input layer 210, the convolution layer/pooling layer 220 and the neural network layer 230, and then the classification result of the image to be processed is output.
  • FIG18 is a chip hardware structure provided in an embodiment of the present application, and the chip includes a neural network processor 50.
  • the chip can be set in the execution device 110 shown in FIG16 to complete the calculation work of the calculation module 111.
  • the chip can also be set in the training device 120 shown in FIG16 to complete the training work of the training device 120 and output the target model/rule 101.
  • the algorithms of each layer in the convolutional neural network shown in FIG17 can be implemented in the chip shown in FIG18.
  • the neural network processor NPU 50 is mounted on the host CPU as a coprocessor, and the host CPU assigns tasks.
  • the core part of the NPU is the operation circuit 503, and the controller 504 controls the operation circuit 503 to extract data from the memory (weight memory or input memory) and perform operations.
  • the operation circuit 503 includes multiple processing units (process engines, PEs) inside.
  • the operation circuit 503 is a two-dimensional systolic array.
  • the operation circuit 503 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition.
  • the operation circuit 503 is a general-purpose matrix processor.
  • the operation circuit 503 takes the corresponding data of the matrix B from the weight memory 502 and caches it on each PE in the operation circuit 503.
  • the operation circuit 503 takes the matrix A data from the input memory 501 and performs a matrix operation with the matrix B, and the partial result or the final result of the matrix is stored in the accumulator 508.
  • the vector calculation unit 507 can further process the output of the operation circuit 503, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc.
  • the vector calculation unit 507 can be used for network calculations of non-convolutional/non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.
  • the vector calculation unit can 507 store the processed output vector to the unified buffer 506.
  • the vector calculation unit 507 can apply a nonlinear function to the output of the operation circuit 503, such as a vector of accumulated values, to generate an activation value.
  • the vector calculation unit 507 generates a normalized value, a merged value, or both.
  • the processed output vector can be used as an activation input to the operation circuit 503, such as for use in a subsequent layer in a neural network.
  • the unified memory 506 is used to store input data and output data.
  • the weight data is directly transferred from the external memory to the input memory 501 and/or the unified memory 506 through the memory unit access controller 505 (direct memory access controller, DMAC), the weight data in the external memory is stored in the weight memory 502, and the data in the unified memory 506 is stored in the external memory.
  • DMAC direct memory access controller
  • the bus interface unit (BIU) 510 is used to realize the interaction between the main CPU, DMAC and instruction fetch memory 509 through the bus.
  • An instruction fetch buffer 509 connected to the controller 504 and used to store instructions used by the controller 504;
  • the controller 504 is used to call the instructions cached in the memory 509 to control the working process of the computing accelerator.
  • the unified memory 506, the input memory 501, the weight memory 502 and the instruction fetch memory 509 are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (DDR SDRAM for short), a high bandwidth memory (HBM) or other readable and writable memory.
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • HBM high bandwidth memory
  • each layer in the convolutional neural network shown in Figure 17 can be performed by the operation circuit 503 or the vector calculation unit 307.
  • the execution device 110 in FIG. 16 described above can execute each step of the image classification method of the embodiment of the present application, and the CNN model shown in FIG. 17 and the chip shown in FIG. 18 can also be used to execute each step of the image classification method of the embodiment of the present application.
  • the image classification method of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
  • the image classification method provided in the embodiment of the present application can be executed on a server, can be executed in the cloud, or can be executed on a terminal device. Taking a terminal device as an example, as shown in FIG19 , the technical solution of the embodiment of the present application can be applied to a terminal device, and the image classification method in the embodiment of the present application can classify an input image to obtain a classification result of the input image.
  • the terminal device can be mobile or fixed, for example, the terminal device can be a mobile phone with an image processing function, a tablet personal computer (tablet personal computer, TPC), a media player, a smart TV, a laptop computer (laptop computer, LC), a personal digital assistant (personal digital assistant, PDA), a personal computer (personal computer, PC), a camera, a video camera, a smart watch, a wearable device (wearable device, WD) or an autonomous driving vehicle, etc., and the embodiment of the present invention does not limit this.
  • Image (or picture) classification is the basis of various image processing applications.
  • Computer vision often involves the problem of how to classify the acquired images.
  • the number of parameters and the amount of calculation of high-precision convolutional neural networks are very large, while the memory and computing resources of terminal devices are very limited, and they do not have strong computing power and cache capacity, making it difficult to deploy high-precision convolutional neural networks on terminal devices.
  • the embodiment of the present application proposes an image classification method, which can obtain the required output feature map by using a small number of standard convolution kernels that are less than the number of standard convolution kernels in existing convolutional neural networks. This method helps to reduce the amount of computation and parameters in image classification processing.
  • FIG20 shows a schematic flow chart of an image classification method 500 provided in an embodiment of the present application.
  • the method may be executed by an apparatus capable of performing image classification.
  • the method may be executed by the terminal device in FIG19 .
  • the image to be processed may be an image captured by the terminal device through a camera, or the image to be processed may also be an image obtained from inside the terminal device (for example, an image stored in the photo album of the terminal device, or an image obtained by the terminal device from the cloud).
  • the input feature map of the image to be processed may be a feature map obtained after processing by other layers in the convolutional neural network.
  • the other layers in the convolutional neural network mentioned here refer to a layer in the convolutional neural network, for example, the other layer may be one of the input layer, convolution layer, pooling layer or fully connected layer in the convolutional neural network.
  • the M convolution kernels can be standard convolution kernels in existing convolutional neural networks.
  • the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map.
  • the number of channels of the input feature map of the image to be processed is C
  • the number of channels of the standard convolution kernel in the existing convolutional neural network is also C, that is, the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map, where C is a positive integer.
  • the number of channels of each of the N matrices is less than M, N is greater than M, and N is a positive integer.
  • S520 and S530 are the feature amplification unit (feature in feature, FiF) in the embodiment of the present application, and the feature amplification unit can be used to replace the convolution layer in the existing convolutional neural network model.
  • the feature amplification unit uses a small number of standard convolution kernels to perform convolution processing to obtain a small number of candidate feature maps, and performs matrix transformation on these small number of candidate feature maps to obtain the required output feature maps, which can reduce the redundancy between the output feature maps and help reduce the amount of calculation and parameters for image classification processing.
  • the feature amplification unit in S520 and S530 is described in detail below in conjunction with Figures 21 and 22.
  • FIG. 21 shows the convolution processing of a convolutional layer in an existing convolutional neural network.
  • the input feature map of the convolution layer includes C channels
  • the output feature map of the convolution layer includes N channels.
  • N standard convolution kernels are required in the convolution layer, and each of the N standard convolution kernels includes C channels.
  • the input feature map of the above C channels may refer to an input feature map, the number of channels of the input feature map is C; or, the input feature map of the above C channels may also refer to C input feature maps, each of which is two-dimensional (i.e., the number of channels is 1).
  • the present application uniformly describes the input feature map of C channels. The descriptions of other feature maps in the embodiments of the present application can be understood similarly and will not be repeated here.
  • a candidate output feature map of M channels is obtained, and the candidate output feature map of M channels can be considered as a candidate output feature map including M channels, or a candidate output feature map with M channels being 1.
  • Figure 22 shows the feature amplification processing of the feature amplification unit in the embodiment of the present application.
  • the feature amplification unit can be used to replace the convolution layer in the existing convolutional neural network (such as the convolution layer shown in Figure 21).
  • the feature amplification unit performs convolution processing based on a small number of standard convolution kernels, and performs matrix variables on each channel of the small number of candidate feature maps obtained, which can effectively reduce the redundancy between the output feature maps.
  • the number of standard convolution kernels in the feature amplification unit is less than that of the existing convolutional neural network, and the number of channels of the matrix used in the matrix transformation is also smaller than the standard convolution kernel. Therefore, it helps to reduce the amount of computation and parameters of the neural network model, thereby reducing the amount of computation and parameters of image classification processing.
  • the N matrices in the above matrix transformation may be matrices with N channels of 1; or the N matrices in the above matrix transformation may also be matrices with N channels greater than 1, for example, The number of channels of the array is 2.
  • the N matrices can also be considered as N convolution kernels.
  • the N matrices can be understood as the N convolution kernels, and the N convolution kernels can also refer to the N matrices for matrix transformation of the candidate output feature maps of the M channels.
  • the convolution kernel in S520 is a standard convolution kernel in an existing convolutional neural network.
  • the number of channels of the standard convolution kernel is the same as the number of channels of the input feature map for convolution.
  • the number of channels of each of the above-mentioned N convolution kernels in the present application can be less than the number of channels M of the input feature map for convolution (i.e., the candidate output feature map of the M channels).
  • the number of channels of the N convolution kernels can be 1.
  • the computational complexity and parameter amount of the feature amplification unit can be reduced.
  • the feature amplification unit is used to replace the convolutional layer in the existing convolutional neural network (such as the convolutional layer shown in Figure 21), it helps to reduce the computational complexity and parameter amount of the neural network model, thereby reducing the computational complexity and parameter amount of the image classification processing.
  • the number of channels of the N matrices in the above matrix transformation may be 1.
  • the N matrices may be divided into M groups of convolution kernels, and the M groups of convolution kernels may respectively correspond to the M channels of the candidate output feature maps.
  • the M groups of convolution kernels may correspond one-to-one to the M channels of the candidate output feature maps.
  • the first group of the M groups of convolution kernels can correspond to the first channel of the M channels of the candidate output feature map
  • the second group of the M groups of convolution kernels can correspond to the second channel of the M channels of the candidate output feature map
  • the Mth group of the M groups of convolution kernels can correspond to the Mth channel of the M channels of the candidate output feature map.
  • performing matrix transformation on the M candidate output feature maps according to N matrices to obtain output feature maps of N channels may include: performing convolution on corresponding channels among the M channels of the candidate output feature maps according to each group of convolution kernels in the M groups of convolution kernels to obtain output feature maps of the N channels.
  • the first group of the M groups of convolution kernels can be used to convolve the first channel of the M channels of the candidate output feature map, ..., the Mth group of the M groups of convolution kernels can be used to convolve the Mth channel of the M channels of the candidate output feature map.
  • the first group of the M groups of convolution kernels includes S convolution kernels (the number of channels of the convolution kernel is 1), such as ⁇ 1,1 to ⁇ 1,s as shown in Figure 22, then these S convolution kernels can be used to convolve the first channel of the M channels of the candidate output feature map to obtain S output feature maps (or it can also be considered as an output feature map with S channels).
  • the other groups of convolution kernels in the M groups of convolution kernels are similar, and may also be S convolution kernels, which will not be described in detail here.
  • the number of floating point operations (FLOPs) r S of the feature amplification unit can be approximately expressed by the following formula (1):
  • S is the number of convolutions included in each group of the M groups of convolution kernels
  • C is the number of channels of the input feature map of the feature amplification unit.
  • the compression ratio r C of the parameter quantity of the feature amplification unit can be approximately expressed by the following formula (3):
  • S is the number of convolutions included in each group of the M groups of convolution kernels
  • C is the number of channels of the input feature map of the feature amplification unit.
  • convolving the corresponding channels among the M channels of the candidate output feature map to obtain the output feature map of the N channels may include: according to each group of convolution kernels in the M groups of convolution kernels, performing depthwise convolution on the corresponding channels among the M channels of the candidate output feature map to obtain the output feature map of the N channels.
  • the depth convolution may refer to the prior art, which will not be described in detail here.
  • the convolution kernel of each group in the M groups of convolution kernels is the same as the convolution kernels of other groups in the M groups of convolution kernels.
  • the M channels of the candidate output feature map can reuse the same convolution kernel for convolution.
  • the first group of the M groups of convolution kernels includes S convolution kernels, such as ⁇ 1,1 to ⁇ 1,s shown in Figure 7, and these S convolution kernels can be used in sequence to perform convolution on the first channel of the M channels of the candidate output feature map;
  • the second group of the M groups of convolution kernels includes S convolution kernels may also be ⁇ 1,1 to ⁇ 1,s shown in Figure 7, and these S convolution kernels can be used in sequence to perform convolution on the second channel of the M channels of the candidate output feature map.
  • the S convolution kernels included in other groups of the M groups of convolution kernels may also be ⁇ 1,1 to ⁇ 1,s as shown in FIG. 22 , which will not be described in detail here.
  • the number of channels of the N matrices in the matrix transformation i.e., the N convolution kernels mentioned above
  • the amount of calculation and the amount of parameters of the feature amplification unit can be reduced, thereby reducing the amount of calculation and the amount of parameters of the image classification processing.
  • the number of channels of the N matrices in the above matrix transformation may be greater than 1.
  • the N matrices can be divided into M/2 groups of convolution kernels, and the M/2 groups of convolution kernels can respectively correspond one-to-one to 2 channels of the M channels of the candidate output feature map.
  • the candidate output feature maps of the M channels are equivalent to being divided into M/2 feature maps with a channel number of 2, which are convolved with the N convolution kernels.
  • the N convolution kernels are also equivalent to being divided into M/2 groups of convolution kernels.
  • the first group of the M/2 groups of convolution kernels can correspond to the first channel and the second channel of the M channels of the candidate output feature map
  • the second group of the M/2 groups of convolution kernels can correspond to the third channel and the fourth channel of the M channels of the candidate output feature map
  • the M/2th group of the M/2 groups of convolution kernels can correspond to the M-1th channel and the Mth channel of the M channels of the candidate output feature map.
  • convolution can be performed on the corresponding channels in the M channels of the candidate output feature map to obtain the output feature map of the N channels.
  • the first group of the M/2 groups of convolution kernels can be used to convolve the first channel and the second channel of the M channels of the candidate output feature map
  • the M/2th group of the M/2 groups of convolution kernels can be used to convolve the M-1th channel and the Mth channel of the M channels of the candidate output feature map.
  • the convolution kernel of each group in the M/2 groups of convolution kernels is the same as the convolution kernel of other groups in the M/2 groups of convolution kernels. That is, the M channels of the candidate output feature map can reuse the same convolution kernel for convolution.
  • the case where the number of channels of the N matrices in the matrix transformation is greater than 2 is similar to the embodiment where the number of channels of the N matrices in the above-mentioned matrix transformation is equal to 2, and will not be repeated here.
  • the number of channels of the N matrices in the matrix transformation i.e., the N convolution kernels mentioned above
  • the amount of calculation and parameters of the feature amplification unit can be reduced, thereby reducing the amount of calculation and parameters of the image classification processing.
  • the number of channels of the N matrices (i.e., the N convolution kernels mentioned above) in the matrix transformation may be equal to the number of channels M of the candidate output feature map.
  • classifying the image to be processed according to the output feature map to obtain the classification result of the image to be processed may include: performing feature splicing on the candidate output feature map and the output feature map to obtain a feature splicing feature map, the number of channels of the feature splicing feature map is M+N; classifying the image to be processed according to the feature splicing feature map to obtain the classification result of the image to be processed.
  • the above-mentioned feature splicing means that the candidate output feature map and the output feature map form a new feature map in the depth direction, that is, the above-mentioned feature splicing feature map.
  • the number of channels of the candidate output feature map is M, and the number of channels of the output feature map is N.
  • the candidate output feature map and the output feature map can be feature spliced to obtain a feature splicing feature map with a channel number of M+N.
  • Feature splicing can introduce more details (or features) into the output feature map through the identity feature mapping.
  • this identity mapping does not introduce additional parameters or calculations, so it can improve the image classification effect without increasing the number of parameters and calculations.
  • S540 Classify the image to be processed according to the output feature map to obtain a classification result of the image to be processed.
  • FIG23 shows a schematic flow chart of an image classification method 800 provided in another embodiment of the present application.
  • the method may be executed by an apparatus capable of performing image classification.
  • the method may be executed by the terminal device in FIG19 .
  • the image to be processed may be an image captured by the terminal device through a camera, or the image to be processed may also be an image obtained from inside the terminal device (for example, an image stored in the photo album of the terminal device, or an image obtained by the terminal device from the cloud).
  • the input feature map of the image to be processed may be a feature map obtained after processing by other layers in the convolutional neural network.
  • the other layers in the convolutional neural network mentioned here refer to a layer in the convolutional neural network, for example, the other layer may be one of the input layer, convolution layer, pooling layer or fully connected layer in the convolutional neural network.
  • the M first convolution kernels can be standard convolution kernels in existing convolutional neural networks.
  • the number of channels of each of the K first matrices is less than M, K is greater than M, and K is a positive integer.
  • the above S820 and S830 can be a feature amplification unit (feature in feature, FiF) in the method 500 of Figure 20.
  • S820 and S830 may also be referred to as first feature amplification units in the following embodiments.
  • the P second convolution kernels can be standard convolution kernels in existing convolutional neural networks.
  • convolving the first output feature map according to the P second convolution kernels of the neural network to obtain second candidate output feature maps of P channels may include: performing depth convolution on the first output feature map to obtain a depth convolution feature map; and convolving the depth convolution feature map according to the P second convolution kernels to obtain the second candidate output feature map.
  • performing a deep convolution on the first output feature map to obtain a deep convolution feature map may include: performing a deep convolution on the first output feature map with a stride greater than 1 to obtain the deep convolution feature map.
  • the number of channels of each of the N second matrices is less than P, N is greater than P, and N is a positive integer.
  • the above S840 and S850 may also be a feature amplification unit (feature in feature, FiF) in the method 500 of Figure 20.
  • S840 and S850 may also be referred to as second feature amplification units in the following embodiments.
  • S860 Classify the image to be processed according to the second output feature map to obtain a classification result of the image to be processed.
  • classifying the image to be processed according to the second output feature map to obtain a classification result of the image to be processed may include: performing a residual connection on the input feature map and the second output feature map to obtain a residual connection feature map; and classifying the image to be processed according to the residual connection feature map to obtain a classification result of the image to be processed.
  • the above-mentioned S820 to S850 may be a spindle block in an embodiment of the present application, and the spindle block may be used to replace a module (block) in an existing convolutional neural network model.
  • a module in an existing convolutional neural network model may include two convolutional layers.
  • spindle modules in the following embodiments all refer to the spindle modules in the method 800 (S820 to S850) of FIG. 23 above.
  • the spindle module is
  • the spindle module may include the above-mentioned first feature amplification unit and the above-mentioned second feature amplification unit.
  • the spindle module can be composed of at least two feature amplification units (such as the feature amplification unit shown in FIG20 ), which use a small number of standard convolution kernels for convolution processing to obtain a small number of candidate feature maps, and perform matrix transformation on these small number of candidate feature maps to obtain the required output feature maps, which can reduce the redundancy between the output feature maps and help reduce the amount of calculation and parameters in the image classification process.
  • the spindle module in S820 to S850 is described in detail below in conjunction with FIG24 and FIG25 .
  • FIG24 shows a spindle module in an embodiment of the present application with a step length of 1.
  • the spindle may be composed of at least two feature amplification units (such as the feature amplification unit shown in FIG20 ).
  • the size (width and height) of the input feature map is the same as the size of the output feature map.
  • the input feature map of the spindle module is the input feature map of the image to be processed
  • the output feature map of the spindle module is the second output feature map of N channels. If the size of the input feature map is A*B, the size of the second output feature map is also A*B.
  • a depth convolution may be performed between the first feature amplification unit and the second feature amplification unit.
  • the step length of the depth convolution may be 1.
  • the spindle module can also be residually connected, that is, the input feature map and the second output feature map are residually connected.
  • the input feature map and the second output feature map can be residually connected to obtain a residual connection feature map; accordingly, the image to be processed can be classified according to the residual connection feature map to obtain a classification result of the image to be processed.
  • Residual connections can be used to introduce more details (or features) into the output feature map, and residual connections do not introduce additional parameters or computational complexity. Therefore, the effect of image classification can be improved without increasing the number of parameters and computational complexity.
  • FIG25 shows a spindle module with a step length greater than 1 in an embodiment of the present application.
  • the spindle may be composed of at least two feature amplification units (such as the feature amplification units shown in FIG20 ).
  • the size (width and height) of the output feature map is smaller than the size of the input feature map.
  • the size (width and height) of the output feature map is half the size of the input feature map.
  • the input feature map of the above-mentioned spindle module is the input feature map of the image to be processed
  • the output feature map of the above-mentioned spindle module is the second output feature map of N channels. If the size of the input feature map is A*B, then the size of the second output feature map is also (A/2)*(B/2).
  • a depth convolution may be performed between the first feature amplification unit and the second feature amplification unit.
  • the step length of the depth convolution may be greater than 1.
  • the number of channels of the output feature map of the spindle module may be N (i.e., the second output feature map of N channels), and the number of channels of the output feature map of the first feature amplification unit may be K (i.e., the output feature map of K channels).
  • the first output feature map can make the number of channels K of the output of the first feature amplification unit greater than N, and accordingly, the number of channels K is reduced to N through the second feature amplification unit.
  • the number of channels can be increased by the first feature amplification unit, and then the number of channels can be reduced by the second feature amplification unit to meet the number of channels output by the spindle module.
  • the number of channels of the output feature map of the spindle module is 100 (i.e., the second output feature map of 100 channels), and the number of channels of the output feature map of the first feature amplification unit may be 1000 (i.e., the first output feature map of 1000 channels).
  • the number of channels 1000 output by the first feature amplification unit is greater than the number of channels 100 output by the spindle module. Accordingly, the number of channels 1000 can be reduced to 100 through the second feature amplification unit.
  • the feature amplification unit in the embodiment of the present application can implement convolution processing in the existing convolutional neural network through a small number of standard convolution kernels and matrix transformations, which can effectively reduce the redundancy between the output feature maps, reduce the computational complexity and parameter amount of the neural network model, and thus reduce the computational complexity and parameter amount of the image classification processing. Therefore, the spindle module in the embodiment of the present application can improve the image classification effect without increasing the parameter amount and computational complexity (or reducing the parameter amount and computational complexity).
  • FIG26 is a schematic block diagram of a neural network provided in an embodiment of the present application.
  • the neural network shown in FIG26 can be used to implement the image classification method shown in FIG23
  • the neural network in Figure 26 may include one or more spindle modules in method 800 of Figure 23, which may be used to replace a block in an existing convolutional neural network model.
  • a module in an existing convolutional neural network model may include two convolutional layers.
  • the spindle module may include at least two feature amplification units shown in FIG20.
  • the spindle module may include two feature amplification units: a first feature amplification unit and a second feature amplification unit as described in method 800 of FIG23.
  • One feature amplification unit may be used to replace a convolutional layer in an existing convolutional neural network model.
  • a convolutional layer In the neural network shown in FIG. 26 , a convolutional layer, a pooling layer, a fully connected layer, etc. may also be included, but this application does not limit this.
  • HWNet includes multiple spindle modules, wherein each spindle module includes a feature amplification module, and the network structure of HWNet can refer to the design criteria of existing neural networks. For example, in the design of existing neural networks, as the size of the feature map gradually decreases, the number of channels of the feature map gradually increases.
  • the specific structure of HWNet can be shown in Table 1 below.
  • the first layer of HWNet is a convolutional layer with 16 standard convolution kernels, followed by 12 spindle modules with gradually increasing channels of input feature maps. These spindle module groups are divided into 5 stages, and the feature maps in each stage have the same size.
  • Table 2 below is the test experimental data of HWNet and several existing neural network models for image classification on the ImageNet dataset.
  • MobileNet is a convolutional neural network model proposed by Google
  • ShuffleNet is a convolutional neural network model designed for mobile terminal devices proposed by Megvii Technology
  • IGCV3 is an interleaved low-rank group convolution.
  • the HWNet proposed in the embodiment of the present application has a higher model accuracy with fewer parameters and faster calculation.
  • FIG27 is a schematic diagram of the hardware structure of the image classification device of an embodiment of the present application.
  • the image classification device 4000 shown in FIG27 includes a memory 4001, a processor 4002, a communication interface 4003 and a bus 4004.
  • the memory 4001, the processor 4002 and the communication interface 4003 are connected to each other through the bus 4004.
  • the memory 4001 may be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM).
  • the memory 4001 may store a program. When the program stored in the memory 4001 is executed by the processor 4002, the processor 4002 and the communication interface 4003 are used to execute the various steps of the image classification method of the embodiment of the present application.
  • Processor 4002 can adopt a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the functions required to be performed by the units in the image classification device of the embodiment of the present application, or to execute the image classification method of the method embodiment of the present application.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • GPU graphics processing unit
  • the processor 4002 may also be an integrated circuit chip with signal processing capability.
  • each step of the image classification method of the embodiment of the present application may be completed by an integrated logic circuit of hardware in the processor 4002 or by instructions in the form of software.
  • the processor 4002 may also be a general-purpose processor, a digital signal processor (DSP), an ASIC, a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components.
  • the general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
  • the steps of the method disclosed in the embodiment of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in the decoding processor.
  • the software module may be located in a mature storage medium in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc.
  • the storage medium is located in the memory 4001, and the processor 4002 reads the information in the memory 4001, and completes the functions required to be performed by the units included in the image classification device of the embodiment of the present application in combination with its hardware, or executes the image classification method of the method embodiment of the present application.
  • the communication interface 4003 uses a transceiver device such as, but not limited to, a transceiver to implement communication between the device 4000 and other devices or a communication network.
  • a transceiver device such as, but not limited to, a transceiver to implement communication between the device 4000 and other devices or a communication network.
  • the image to be processed can be obtained through the communication interface 4003.
  • the bus 4004 may include a path for transmitting information between various components of the device 4000 (eg, the memory 4001 , the processor 4002 , and the communication interface 4003 ).
  • FIG28 is a schematic diagram of the hardware structure of a neural network training device 5000 according to an embodiment of the present application. Similar to the above-mentioned device 4000, the neural network training device 5000 shown in FIG28 includes a memory 5001, a processor 5002, a communication interface 5003, and a bus 5004. The memory 5001, the processor 5002, and the communication interface 5003 are connected to each other through the bus 5004.
  • the memory 5001 can store programs. When the program stored in the memory 5001 is executed by the processor 5002, the processor 5002 is used to execute each step of the training method of the image classification device of the embodiment of the present application.
  • the processor 5002 may be a general-purpose CPU, a microprocessor, an ASIC, a GPU, or one or more integrated circuits. Used to execute relevant programs to implement the training method of the image classification device of the embodiment of the present application.
  • the processor 5002 may also be an integrated circuit chip with signal processing capability.
  • each step of the training method of the image classification device of the embodiment of the present application may be completed by hardware integrated logic circuits in the processor 5002 or software instructions.
  • the trained image classification device can be used to execute the image classification method of the embodiment of the present application. Specifically, by training the neural network through the device 5000, the neural network in the method shown in Figure 20 or Figure 23 can be obtained.
  • the device shown in FIG. 28 can obtain training data and an image classification device to be trained from the outside through the communication interface 5003 , and then the processor trains the image classification device to be trained according to the training data.
  • apparatus 4000 and apparatus 5000 only show a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the apparatus 4000 and apparatus 5000 may also include other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the apparatus 4000 and apparatus 5000 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the apparatus 4000 and apparatus 5000 may also only include the devices necessary for implementing the embodiments of the present application, and do not necessarily include all the devices shown in Figures 27 and 28.
  • the processor in the embodiment of the present application may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
  • the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories.
  • the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.
  • the volatile memory may be a random access memory (RAM), which is used as an external cache.
  • RAM random access memory
  • SRAM static RAM
  • DRAM dynamic random access memory
  • SDRAM synchronous DRAM
  • DDR SDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous link DRAM
  • DR RAM direct rambus RAM
  • the above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination.
  • the above embodiments can be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions or computer programs.
  • the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part.
  • the computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions can be transmitted from a website, a computer, a server or a data center.
  • the computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media.
  • the available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium.
  • the semiconductor medium may be a solid state drive.
  • At least one means one or more, and “more than one” means two or more.
  • At least one of the following” or similar expressions refers to any combination of these items, including any combination of single or plural items.
  • at least one of a, b, or c can mean: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, c can be single or multiple.
  • the size of the serial numbers of the above-mentioned processes does not mean the order of execution.
  • the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
  • the disclosed systems, devices and methods can be implemented in other ways.
  • the device embodiments described above are only schematic.
  • the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
  • Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Image Analysis (AREA)

Abstract

一种数据处理方法,应用于人工智能领域,方法包括:根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及存储地址,存储地址对应的存储空间位于计算单元之外的存储空间;从存储空间中获取一个或多个目标网络单元;根据目标词向量,通过计算单元执行根据一个或多个目标网络单元构建的神经网络对应的训练过程。本申请中由于大规模模型中的目标网络单元存储在计算单元之外的存储位置,在当前的训练样本为对应的词向量时,从计算单元之外的存储位置中提取对应的一个或多个目标网络单元,由于计算单元之外的存储位置的存储空间可以设置的较大,通过存算分离,可以提高训练时大规模模型自身的大小,并增加大规模模型的可扩展性和灵活度。

Description

一种数据处理方法及相关装置 技术领域
本申请涉及人工智能领域,尤其涉及一种数据处理方法及相关装置。
背景技术
人工智能(artificial intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式作出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。
近年来,随着计算芯片技术和大规模计算集群的快速发展,越来越多的大模型开始出现,千亿甚至万亿级别的大模型成为最近甚至未来一段时间的主流技术趋势。但是,大模型最核心的问题在于,训练和使用成本极其高昂,通常需要数百块,甚至几千块GPU、TPU或者NPU芯片等计算单元组成的超大规模集群,计算数周甚至数个月时间,成本以百万至千万美元计。这个核心问题的另一个问题是,成本如此高昂的模型,如何设计和训练,以充分发挥其价值,并在设计之初,就要为未来可能的未知的使用场景做出准备,因为成本如此高昂的模型,是不可能被一遍一遍的重新训练的,因此需要有某种形式能够保存以前训练的成果,并能够为未来的可能使用场景做准备。
在一种实现方案中,可以将大规模模型划分为多个网络单元,针对于不同的输入样本(例如不同的词向量),设置有对应的网络单元,在使用某一输入样本进行模型训练时,多个网络单元中仅该输入样本对应的网络单元被更新,且更新后的网络单元会被存储起来,以便下一次更新时被调用。
在现有技术中,通常使用计算单元中的内存来存储大模型,计算单元中的内存较小,限制了大规模模型自身的大小。
发明内容
本申请提供了一种数据处理方法,可以提高大规模模型自身的大小,并增加大规模模型的可扩展性和灵活度。
第一方面,本申请实施例提供了一种数据处理方法,所述方法包括:根据目标映射关系,确定目标词向量token对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址,所述存储地址对应的存储空间位于计算单元之外的存储空间;从所述存储地址对应的存储空间中获取所述一个或多个目标网络单元;所述一个或多个目标网络单元用于构建神经网络;根据所述目标词向量,通过所述计算单元执行所述神经网络对应的训练过程。
由于大规模模型中的目标网络单元存储在计算单元之外的存储位置,在当前的训练样本为对应的词向量时,从计算单元之外的存储位置中提取对应的一个或多个目标网络单 元,由于计算单元之外的存储位置的存储空间可以设置的较大,通过存算分离,可以提高大规模模型自身的大小,并增加大规模模型的可扩展性和灵活度。
在一种可能的实现中,所述目标网络单元为前向传播网络FFN。
在一种可能的实现中,所述计算单元为图形处理器GPU、张量处理器TPU或者神经网络处理器NPU。
在一种可能的实现中,所述存储地址对应的存储空间位于内存、网络存储器或者硬盘。
在一种可能的实现中,所述目标映射关系包括第一目标映射关系,所述第一目标映射关系指示多个词向量以及每个词向量对应的一个或多个网络单元,所述第一目标映射关系具体为映射表。
在现有技术中,通过散列hash的方式来构建训练样本(词向量token)和网络单元之间的映射关系,由于散列hash中一个训练样本仅能对应唯一一个网络单元,且由于散列hash中存在数值范围限制,随着训练样本的增大,可能会出现大量不同的训练样本对应于同一个网络单元的情况,使得训练后的模型的精度受到影响。本申请中,通过映射表的方式来记载训练样本(词向量token)和网络单元之间的映射关系,可以实现一个训练样本对应多个网络单元,且由于没有数值范围限制,不会出现大量不同的训练样本对应于同一个网络单元的情况,进而可以增大训练后的模型的精度。
在一种可能的实现中,所述通过所述计算单元执行所述目标神经网络对应的训练过程用于得到更新后的目标神经网络,所述更新后的目标神经网络包括更新后的所述一个或多个目标网络单元,所述方法还包括:根据所述更新后的所述一个或多个目标网络单元,更新所述存储地址对应的存储空间中的数据。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述方法还包括:接收到用户针对于第二目标映射关系的修改信息,其中,所述第二目标映射关系包括多个词向量以及每个词向量对应的网络单元;根据所述修改信息,修改第二目标映射关系,以得到所述目标映射关系。
在一种可能的实现中,所述修改信息用于指示如下的至少一种:对所述第二目标映射关系中至少一个词向量对应的网络单元的删除、替换或者增加;对所述第二目标映射关系中包括的映射关系的删除、替换或者增加,所述映射关系为词向量以及词向量对应的网络单元。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述方法还包括:在通过所述目标词向量对所述神经网络执行训练过程中,基于训练损失的下降程度低于阈值,对第二目标映射关系中所述目标词向量对应的网络单元进行增加,以得到所述目标映射关系。在训练损失的下降程度较低时,可以表示模型当前的性能无法再继续提高了,这时候可以通过增加网络单元来改变神经网络的结构,使得训练的损失可以继续下降。
在一种可能的实现中,所述目标映射关系包括多个词单元以及每个词单元对应的网络单元,所述方法还包括:
根据收敛后所述神经网络,从所述目标映射关系中包括的多个词单元中确定部分词单元对应的网络单元,所述收敛后所述神经网络中所述部分词单元对应的网络单元用于构建目标神经网络;所述目标神经网络用于进行模型推理。
第二方面,本申请提供了一种数据处理装置,所述装置包括:
处理模块,用于根据目标映射关系,确定目标词向量token对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址,所述存储地址对应的存储空间位于计算单元之外的存储空间;
从所述存储地址对应的存储空间中获取所述一个或多个目标网络单元;所述一个或多个目标网络单元用于构建神经网络;
模型训练模块,用于根据所述目标词向量,通过所述计算单元执行所述神经网络对应的训练过程。
在一种可能的实现中,所述目标网络单元为前向传播网络FFN。
在一种可能的实现中,所述计算单元为图形处理器GPU、张量处理器TPU或者神经网络处理器NPU。
在一种可能的实现中,所述存储地址对应的存储空间位于内存、网络存储器或者硬盘。
在一种可能的实现中,所述目标映射关系包括第一目标映射关系,所述第一目标映射关系指示多个词向量以及每个词向量对应的一个或多个网络单元,所述第一目标映射关系具体为映射表。
在一种可能的实现中,所述通过所述计算单元执行所述目标神经网络对应的训练过程用于得到更新后的目标神经网络,所述更新后的目标神经网络包括更新后的所述一个或多个目标网络单元,所述处理模块,还用于:
根据所述更新后的所述一个或多个目标网络单元,更新所述存储地址对应的存储空间中的数据。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述处理模块,还用于:
接收到用户针对于第二目标映射关系的修改信息,其中,所述第二目标映射关系包括多个词向量以及每个词向量对应的网络单元;
根据所述修改信息,修改第二目标映射关系,以得到所述目标映射关系。
在一种可能的实现中,所述修改信息用于指示如下的至少一种:
对所述第二目标映射关系中至少一个词向量对应的网络单元的删除、替换或者增加;
对所述第二目标映射关系中包括的映射关系的删除、替换或者增加,所述映射关系为词向量以及词向量对应的网络单元。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述处理模块,还用于:
在通过所述目标词向量对所述神经网络执行训练过程中,基于训练损失的下降程度低于阈值,对第二目标映射关系中所述目标词向量对应的网络单元进行增加,以得到所述目标映射关系。
在一种可能的实现中,所述目标映射关系包括多个词单元以及每个词单元对应的网络单元,所述处理模块,还用于:
根据收敛后所述神经网络,从所述目标映射关系中包括的多个词单元中确定部分词单元对应的网络单元,所述收敛后所述神经网络中所述部分词单元对应的网络单元用于构建目标神经网络;所述目标神经网络用于进行模型推理。
第三方面,本申请实施例提供了一种数据处理装置,可以包括存储器、处理器以及总线系统,其中,存储器用于存储程序,处理器用于执行存储器中的程序,以执行如上述第一方面任一可选的方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行上述第一方面及任一可选的方法。
第五方面,本申请实施例提供了一种计算机程序产品,包括代码,当代码被执行时,用于实现上述第一方面及任一可选的方法。
第六方面,本申请提供了一种芯片系统,该芯片系统包括处理器,用于支持数据处理装置实现上述方面中所涉及的功能,例如,发送或处理上述方法中所涉及的数据;或,信息。在一种可能的设计中,芯片系统还包括存储器,所述存储器,用于保存执行设备或训练设备必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包括芯片和其他分立器件。
本申请还提供一种图像分类方法及装置,该方法有助于降低图像分类处理的计算量和参数量。
第七方面,提供了一种图像分类方法,该方法包括:获取待处理图像的输入特征图;根据神经网络的M个卷积核对所述输入特征图进行卷积处理,得到M个通道的候选输出特征图,M为正整数;根据N个矩阵对所述候选输出特征图的M个通道进行矩阵变换,得到N个通道的输出特征图,其中,所述N个矩阵中的每个矩阵的通道数小于M,N大于M,N为正整数;根据所述输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,所述M个卷积核可以为现有卷积神经网络中的标准卷积核。
需要说明的是,在本申请实施例中,标准卷积核的通道数与输入特征图的通道数相同,例如,若待处理图像的输入特征图的通道数为C,那么,现有卷积神经网络中的标准卷积核的通道数也为C,即标准卷积核的通道数与输入特征图的通道数相同,其中,C为正整数。
在本申请实施例中,通过少量标准卷积核(即M个卷积核)对待处理图像进行卷积处理,得到少量的候选特征图,并对这些少量的候选特征图进行矩阵变换以得到所需的输出特征图,其中,标准卷积核的个数少于现有卷积神经网络中的标准卷积核的个数,同时,矩阵变换中使用的矩阵的通道数也小于标准卷积核,因此,有助于减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量。
可选地,所述N个矩阵中每个矩阵的通道数可以为1,或者,所述N个矩阵中每个矩阵的通道数也可以大于1。
结合第七方面,在第七方面的某些实现方式中,所述N个矩阵包括M组卷积核,所述M组卷积核分别与所述候选输出特征图的M个通道对应;所述根据N个矩阵对所述M个候选输出特征图进行矩阵变换,得到N个通道的输出特征图,包括:根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行卷积,得到所述N个通道的输出特征图。
结合第七方面,在第七方面的某些实现方式中,所述根据所述M组卷积核中的每一 组卷积核,对所述候选输出特征图的M个通道中对应的通道进行卷积,得到所述N个通道的输出特征图,包括:根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行深度卷积,得到所述N个通道的输出特征图。
结合第七方面,在第七方面的某些实现方式中,所述M组卷积核中的每一组的卷积核与所述M组卷积核中的其他组的卷积核相同。
结合第七方面,在第七方面的某些实现方式中,所述根据所述输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果,包括:对所述候选输出特征图和所述输出特征图进行特征拼接,得到特征拼接特征图,所述特征拼接特征图的通道数为M+N;根据所述特征拼接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,上述特征拼接可以是指所述候选输出特征图和所述输出特征图在深度方向上组成新的特征图,即上述特征拼接特征图。
例如,所述候选输出特征图的通道数为M,所述输出特征图的通道数为N,所述候选输出特征图和所述输出特征图可以进行特征拼接,得到一个通道数为M+N的特征拼接特征图。
特征拼接可以通过恒等特征映射的方式,可以将更多的细节(或特征)引入输出特征图,同时,这种恒等映射并不会引入额外的参数或者计算量,因此可以在不增加参数量和计算量的情况下,提升图像分类的效果。
第八方面,提供了一种图像分类方法,该方法包括:获取待处理图像的输入特征图;根据神经网络的M个第一卷积核对所述输入特征图进行卷积处理,得到M个通道的第一候选输出特征图,M为正整数;根据K个第一矩阵对所述M个第一候选输出特征图进行矩阵变换,得到K个通道的第一输出特征图,其中,所述K个第一矩阵中的每个矩阵的通道数小于M,K大于M,K为正整数;根据神经网络的P个第二卷积核对所述第一输出特征图进行卷积处理,得到P个通道的第二候选输出特征图,P为正整数;根据N个第二矩阵对所述P个第二候选输出特征图进行矩阵变换,得到N个通道的第二输出特征图,其中,所述N个第二矩阵中的每个矩阵的通道数小于P,N大于P,N为正整数;根据所述第二输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,所述M个第一卷积核可以为现有卷积神经网络中的标准卷积核。
需要说明的是,在本申请实施例中,标准卷积核的通道数与输入特征图的通道数相同,例如,若待处理图像的输入特征图的通道数为C,那么,现有卷积神经网络中的标准卷积核的通道数也为C,即标准卷积核的通道数与输入特征图的通道数相同,其中,C为正整数。
类似地,所述P个第二卷积核也可以为现有卷积神经网络中的标准卷积核。
在本申请实施例中,通过少量标准卷积核及矩阵变换实现现有卷积神经网络中的卷积处理,可以有效减少各输出特征图之间的冗余性,减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量,因此,本申请实施例中的图像分类方法可以在不增加参数量和计算量(或者减少参数量和计算量)的情况下,提升图像分类的效果。
可选地,所述K个第一矩阵中每个矩阵的通道数可以为1,或者,所述K个第一矩阵中每个矩阵的通道数也可以大于1。
可选地,所述N个第二矩阵中每个矩阵的通道数可以为1,或者,所述N个第二矩阵中每个矩阵的通道数也可以大于1。
结合第八方面,在第八方面的某些实现方式中,所述根据神经网络的P个第二卷积核对所述第一输出特征图进行卷积处理,得到P个通道的第二候选输出特征图,包括:对所述第一输出特征图进行深度卷积,得到深度卷积特征图;根据所述P个第二卷积核对所述深度卷积特征图进行卷积处理,得到所述第二候选输出特征图。
结合第八方面,在第八方面的某些实现方式中,所述对所述第一输出特征图进行深度卷积,得到深度卷积特征图,包括:对所述第一输出特征图进行步幅大于1的深度卷积,得到所述深度卷积特征图。
结合第八方面,在第八方面的某些实现方式中,所述根据所述第二输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果,包括:对所述输入特征图和所述第二输出特征图进行残差连接,得到残差连接特征图;根据所述残差连接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
在本申请实施例中,通过残差连接可以将更多的细节(或特征)引入输出特征图,而残差连接并不会引入额外的参数或者计算量,因此,可以在不增加参数量和计算量的情况下,提升图像分类的效果。
第九方面,提供了一种图像分类装置,包括:获取单元,用于获取待处理图像的输入特征图;卷积单元,用于根据神经网络的M个卷积核对所述输入特征图进行卷积处理,得到M个通道的候选输出特征图,M为正整数;矩阵变换单元,用于根据N个矩阵对所述候选输出特征图的M个通道进行矩阵变换,得到N个通道的输出特征图,其中,所述N个矩阵中的每个矩阵的通道数小于M,N大于M,N为正整数;分类单元,用于根据所述输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,所述M个卷积核可以为现有卷积神经网络中的标准卷积核。
需要说明的是,在本申请实施例中,标准卷积核的通道数与输入特征图的通道数相同,例如,若待处理图像的输入特征图的通道数为C,那么,现有卷积神经网络中的标准卷积核的通道数也为C,即标准卷积核的通道数与输入特征图的通道数相同,其中,C为正整数。
在本申请实施例中,通过少量标准卷积核(即M个卷积核)对待处理图像进行卷积处理,得到少量的候选特征图,并对这些少量的候选特征图进行矩阵变换以得到所需的输出特征图,其中,标准卷积核的个数少于现有卷积神经网络中的标准卷积核的个数,同时,矩阵变换中使用的矩阵的通道数也小于标准卷积核,因此,有助于减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量。
可选地,所述N个矩阵中每个矩阵的通道数可以为1,或者,所述N个矩阵中每个矩阵的通道数也可以大于1。
结合第九方面,在第九方面的某些实现方式中,所述N个矩阵包括M组卷积核,所述M组卷积核分别与所述候选输出特征图的M个通道对应;所述矩阵变换单元具体用于:根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行卷积,得到所述N个通道的输出特征图。
结合第九方面,在第九方面的某些实现方式中,所述矩阵变换单元具体用于:根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行深度卷积,得到所述N个通道的输出特征图。
结合第九方面,在第九方面的某些实现方式中,所述M组卷积核中的每一组的卷积 核与所述M组卷积核中的其他组的卷积核相同。
结合第九方面,在第九方面的某些实现方式中,所述分类单元具体用于:对所述候选输出特征图和所述输出特征图进行特征拼接,得到特征拼接特征图,所述特征拼接特征图的通道数为M+N;根据所述特征拼接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,上述特征拼接可以是指所述候选输出特征图和所述输出特征图在深度方向上组成新的特征图,即上述特征拼接特征图。
例如,所述候选输出特征图的通道数为M,所述输出特征图的通道数为N,所述候选输出特征图和所述输出特征图可以进行特征拼接,得到一个通道数为M+N的特征拼接特征图。
特征拼接可以通过恒等特征映射的方式,可以将更多的细节(或特征)引入输出特征图,同时,这种恒等映射并不会引入额外的参数或者计算量,因此可以在不增加参数量和计算量的情况下,提升图像分类的效果。
第十方面,提供了一种图像分类装置,包括:获取单元,用于获取待处理图像的输入特征图;第一卷积单元,用于根据神经网络的M个第一卷积核对所述输入特征图进行卷积处理,得到M个通道的第一候选输出特征图,M为正整数;第一矩阵变换单元,用于根据K个第一矩阵对所述M个第一候选输出特征图进行矩阵变换,得到K个通道的第一输出特征图,其中,所述K个第一矩阵中的每个矩阵的通道数小于M,K大于M,K为正整数;第二卷积单元,用于根据神经网络的P个第二卷积核对所述第一输出特征图进行卷积处理,得到P个通道的第二候选输出特征图,P为正整数;第二矩阵变换单元,用于根据N个第二矩阵对所述P个第二候选输出特征图进行矩阵变换,得到N个通道的第二输出特征图,其中,所述N个第二矩阵中的每个矩阵的通道数小于P,N大于P,N为正整数;分类单元,用于根据所述第二输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,所述M个第一卷积核可以为现有卷积神经网络中的标准卷积核。
需要说明的是,在本申请实施例中,标准卷积核的通道数与输入特征图的通道数相同,例如,若待处理图像的输入特征图的通道数为C,那么,现有卷积神经网络中的标准卷积核的通道数也为C,即标准卷积核的通道数与输入特征图的通道数相同,其中,C为正整数。
类似地,所述P个第二卷积核也可以为现有卷积神经网络中的标准卷积核。
在本申请实施例中,通过少量标准卷积核及矩阵变换实现现有卷积神经网络中的卷积处理,可以有效减少各输出特征图之间的冗余性,减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量,因此,本申请实施例中的图像分类方法可以在不增加参数量和计算量(或者减少参数量和计算量)的情况下,提升图像分类的效果。
可选地,所述K个第一矩阵中每个矩阵的通道数可以为1,或者,所述K个第一矩阵中每个矩阵的通道数也可以大于1。
可选地,所述N个第二矩阵中每个矩阵的通道数可以为1,或者,所述N个第二矩阵中每个矩阵的通道数也可以大于1。
结合第十方面,在第十方面的某些实现方式中,所述图像分类装置还包括深度卷积单元,用于:对所述第一输出特征图进行深度卷积,得到深度卷积特征图;所述第二卷积单 元具体用于:根据所述P个第二卷积核对所述深度卷积特征图进行卷积处理,得到所述第二候选输出特征图。
结合第十方面,在第十方面的某些实现方式中,所述深度卷积单元具体用于:对所述第一输出特征图进行步幅大于1的深度卷积,得到所述深度卷积特征图。
结合第十方面,在第十方面的某些实现方式中,所述图像分类装置还包括残差连接单元,用于:对所述输入特征图和所述第二输出特征图进行残差连接,得到残差连接特征图;所述分类单元具体用于:根据所述残差连接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
在本申请实施例中,通过残差连接可以将更多的细节(或特征)引入输出特征图,而残差连接并不会引入额外的参数或者计算量,因此,可以在不增加参数量和计算量的情况下,提升图像分类的效果。
第十一方面,提供了一种图像分类装置,该装置包括:存储器,用于存储程序;处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行上述第一方面或第二方面中的任意一种实现方式中的方法。
上述第五方面中的处理器既可以是中央处理器(central processing unit,CPU),也可以是CPU与神经网络运算处理器的组合,这里的神经网络运算处理器可以包括图形处理器(graphics processing unit,GPU)、神经网络处理器(neural-network processing unit,NPU)和张量处理器(tensor processing unit,TPU)等等。其中,TPU是谷歌(google)为机器学习全定制的人工智能加速器专用集成电路。
第十二方面,提供一种计算机可读介质,该计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行第一方面或第二方面中的任意一种实现方式中的方法。
第十三方面,提供一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述第一方面或第二方面中的任意一种实现方式中的方法。
第十四方面,提供一种芯片,所述芯片包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,执行上述第一方面或第二方面中的任意一种实现方式中的方法。
可选地,作为一种实现方式,所述芯片还可以包括存储器,所述存储器中存储有指令,所述处理器用于执行所述存储器上存储的指令,当所述指令被执行时,所述处理器用于执行第一方面或第二方面中的任意一种实现方式中的方法。
上述芯片具体可以是现场可编程门阵列(field-programmable gate array,FPGA)或者专用集成电路(application-specific integrated circuit,ASIC)。
第十五方面,提供了一种电子设备,该电子设备包括上述第三方面或第四方面中的任意一个方面中的图像分类装置。
当上述电子设备包括上述第九方面或第十方面中的任意一个方面中的图像分类装置时,该电子设备具体可以是终端设备或服务器。
在本申请实施例中,通过少量标准卷积核(即M个卷积核)对待处理图像进行卷积处理,得到少量的候选特征图,并对这些少量的候选特征图进行矩阵变换以得到所需的输出特征图,其中,标准卷积核的个数少于现有卷积神经网络中的标准卷积核的个数,同时,矩阵变换中使用的矩阵的通道数也小于标准卷积核,因此,有助于减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量。
附图说明
图1为人工智能主体框架的一种结构示意图;
图2为本发明的应用系统框架示意;
图3为本发明的应用系统框架示意;
图4A为一种网络的结构示意图;
图4B为一种网络的结构示意图;
图5为一种数据处理方法的流程示意;
图6为一种数据处理方法的流程示意;
图7为一种数据处理方法的流程示意;
图8为一种数据处理方法的流程示意;
图9为一种数据处理方法的流程示意;
图10为一种数据处理方法的流程示意;
图11为一种数据处理方法的流程示意;
图12为本申请实施例提供的一种数据处理装置的结构示意图;
图13为本申请实施例提供的一种执行设备的示意图;
图14为本申请实施例提供的一种训练设备的示意图;
图15为本申请实施例提供的一种芯片的示意图;
图16是本申请实施例提供的系统架构的结构示意图。
图17是本申请实施例提供的根据卷积神经网络模型进行图像分类的示意图。
图18是本申请实施例提供的一种芯片硬件结构示意图。
图19是本申请实施例提供的一种应用场景示意图。
图20是本申请一个实施例提供的图像分类方法的示意性流程图。
图21是本申请实施例提供的卷积处理的示意性框图。
图22是本申请实施例提供的特征扩增单元的示意性框图。
图23是本申请另一个实施例提供的图像分类方法的示意性流程图。
图24是本申请一个实施例提供的纺锤模块的示意性框图。
图25是本申请另一个实施例提供的纺锤模块的示意性框图。
图26是本申请实施例提供的神经网络的示意性框图。
图27是本申请实施例的图像分类装置的硬件结构示意图。
图28是本申请实施例的神经网络训练装置的硬件结构示意图。
具体实施方式
下面结合本发明实施例中的附图对本发明实施例进行描述。本发明的实施方式部分使用的术语仅用于对本发明的具体实施例进行解释,而非旨在限定本发明。
下面结合附图,对本申请的实施例进行描述。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分 方式。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。
首先对人工智能系统总体工作流程进行描述,请参见图1,图1示出的为人工智能主体框架的一种结构示意图,下面从“智能信息链”(水平轴)和“IT价值链”(垂直轴)两个维度对上述人工智能主题框架进行阐述。其中,“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到系统的产业生态过程,反映人工智能为信息技术产业带来的价值。
(1)基础设施
基础设施为人工智能系统提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。通过传感器与外部沟通;计算能力由智能芯片(CPU、NPU、GPU、ASIC、FPGA等硬件加速芯片)提供;基础平台包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。举例来说,传感器和外部沟通获取数据,这些数据提供给基础平台提供的分布式计算系统中的智能芯片进行计算。
(2)数据
基础设施的上一层的数据用于表示人工智能领域的数据来源。数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有系统的业务数据以及力、位移、液位、温度、湿度等感知数据。
(3)数据处理
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。
(4)通用能力
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用系统,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。
(5)智能产品及行业应用
智能产品及行业应用指人工智能系统在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能终端、智能交通、智能医疗、自动驾驶、智慧城市等。
本申请实施例可以应用于信息推荐领域,该场景包括但不限于涉及电商产品推荐、搜索引擎结果推荐、应用市场推荐、音乐推荐、视频推荐等场景,各种不同应用场景中被推荐的物品也可以称为“对象”以方便后续描述,即在不同的推荐场景中,推荐对象可以是APP,或者视频,或者音乐,或者某款商品(如线上购物平台的呈现界面,会根据用户的不同而显示不同的商品进行呈现,这实质也可以是通过推荐模型的推荐结果来进行呈现)。 这些推荐场景通常涉及用户行为日志采集、日志数据预处理(例如,量化、采样等)、样本集训练以获得推荐模型、根据推荐模型对训练样本项对应的场景中所涉及的对象(如APP、音乐等)进行分析处理、例如,推荐模型训练环节中所选择的样本来自于手机应用市场用户对于所推荐APP的操作行为,则由此所训练出来的推荐模型则适用于上述手机APP应用市场,或者可以用于其它的类型的终端的APP应用市场进行终端APP的推荐。推荐模型将最终计算出各个待推荐对象的推荐概率或者分值,推荐系统根据一定的选择规则选定的推荐结果,例如按照推荐概率或者分值进行排序,通过相应的应用或者终端设备呈现给用户、用户对推荐结果中的对象进行操作以生成用户行为日志等环节。
参照图4A,在推荐过程中,当一个用户与推荐系统进行交互会触发一个推荐请求,推荐系统会将该请求及其相关的特征信息输入到部署的推荐模型中,然后预测用户对所有候选对象的点击率。随后,根据预测的点击率对候选对象进行降序排列,按顺序将候选对象展示在不同的位置作为对用户的推荐结果。用户对展示的项目进行浏览并发生用户行为,如浏览、点击和下载等。这些用户行为会被存入日志中作为训练数据,通过离线训练模块不定期地更新推荐模型的参数,提高模型的推荐效果。
比如,用户打开手机应用市场即可触发应用市场的推荐模块,应用市场的推荐模块会根据用户的历史下载记录、用户点击记录,应用的自身特征,时间、地点等环境特征信息,预测用户对给定的各个候选应用的下载可能性。根据预测的结果,应用市场按照可能性降序展示,达到提高应用下载概率的效果。具体来说,将更有可能下载的应用排在靠前的位置,将不太可能下载的应用排列在靠后的位置。而用户的行为也会存入日志并通过离线训练模块对预测模型的参数进行训练和更新。
又比如,在终身伴侣相关的应用中,可以基于用户在视频、音乐、新闻等域的历史数据,通过各种模型和算法,仿照人脑机制,构建认知大脑,搭建用户终身学习系统框架。终身伴侣可以根据系统数据和应用数据等来记录用户过去发生的事件,理解用户的当前意图,预测用户未来的动作或行为,最终实现智能服务。在当前第一阶段,根据音乐APP、视频APP和浏览器APP等获取用户的行为数据(包含端侧短信、照片、邮件事件等信息),一方面构建用户画像系统,另一方面实现基于用户信息过滤、关联分析、跨域推荐、因果推理等的学习与记忆模块,构建用户个人知识图谱。
接下来介绍本申请实施例的应用架构。
参见附图2,本发明实施例提供了一种推荐系统架构200。数据采集设备260用于采集样本,一个训练样本可以由多个特征信息(或者描述为属性信息,例如用户属性以及物品属性)组成,特征信息可以有多种,具体可以包括用户特征信息和对象特征信息以及标签特征,用户特征信息用于表征用户的特征,例如性别,年龄,职业,爱好等,对象特征信息用于表征向用户所推送的对象的特征,不同的推荐系统对应不同的对象,不同的对象所需要提取的特征类型也不想同,例如APP市场的训练样本中所提取的对象特征可以为,APP的名称(标识),类型,大小等;而电商类APP的训练样本中所提起的对象特征可以为,商品的名称,所属的类别,价格区间等;标签特征,则是用于表示这个样本是正例还是负例,通常样本的标签特征可以通过用户对所推荐对象的操作信息所获的,用户对所推荐对象有进行操作的样本为正例,用户对所推荐对象没有进行操作,或者仅浏览的样本为负例,例如当用户点击或者下载或者购买了所推荐的对象,则所述标签特征为1,表示该样本是正例,而如果用户没有对所推荐的对象进行任何操作,则所述标签特征为0,表示该样本 是负例。样本在采集后可以保存在数据库230中,数据库230中的样本中的部分或全部特征信息也可以直接从客户设备240中获取,如用户特征信息,用户对对象的操作信息(用于确定类型标识),对象特征信息(如对象标识)等。训练设备220基于数据库230中样本训练获取模型参数矩阵用于生成推荐模型201。下面将更详细地描述训练设备220如何训练得到用于生成推荐模型201的模型参数矩阵,推荐模型201能够用于对大量对象进行评估从而得出各个待推荐对象的分值,进一步的还可以从大量对象的评估结果中推荐指定或者预设数目个对象,计算模块211基于推荐模型201的评估结果获取推荐结果,通过I/O接口212推荐给客户设备。
在本申请实施例中,该训练设备220可以从数据库230中样本集内选取正、负样本添加到所述训练集中,之后采用推荐模型对训练集中的样本进行训练从而得到训练后的推荐模型;计算模块211的实现细节可以参照图5所示的方法实施例的详细描述。
训练设备220基于样本训练获得模型参数矩阵后用于构建推荐模型201后,将推荐模型201发送给执行设备210,或者直接将模型参数矩阵发送给执行设备210,在执行设备210中构建推荐模型,用于进行相应系统的推荐,例如基于视频相关的样本训练获得的推荐模型可以用于视频网站或APP中对用户进行视频的推荐,基于APP相关的样本训练获得的推荐模型可以用于应用市场中对用户进行APP的推荐。
执行设备210配置有I/O接口212,与外部设备进行数据交互,执行设备210可以通过I/O接口212从客户设备240获取用户特征信息,例如用户标识、用户身份、性别、职业、爱好等,此部分信息也可以从系统数据库中获取。推荐模型201基于用户特征信息和待推荐对象特征信息向用户推荐目标推荐对象。执行设备210可以设置在云端服务器中,也可以设置于用户客户端中。
执行设备210可以调用数据存储系统250中的数据、代码等,同时也可以将输出的数据存入数据存储系统250中。数据存储系统250可以设置于执行设备210中,也可以独立设置,或者设置于其他网络实体中,数量可以是一个也可以是多个。
计算模块211使用推荐模型201对用户特征信息,待推荐对象特征信息进行处理,例如,该计算模块211使用推荐模型201对用户特征信息,以及待推荐对象的特征信息进行分析处理,从而得出该待推荐对象的分值,对待推荐对象按照分值进行排序,其中,排序靠前的对象将作为推荐给客户设备240的对象。
最后,I/O接口212将推荐结果返回给客户设备240,呈现给用户。
更深层地,训练设备220可以针对不同的目标,基于不同的样本特征信息生成相应的推荐模型201,以给用户提供更佳的结果。
值得注意的,附图2仅是本发明实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在附图2中,数据存储系统250相对执行设备210是外部存储器,在其它情况下,也可将数据存储系统250置于执行设备210中。
在本申请实施例中,该训练设备220、执行设备210、客户设备240可以分别为三个不同的物理设备,也可能该训练设备220和执行设备210在同一个物理设备或者一个集群上,也可能该执行设备210与该客户设备240在同一个物理设备或者一个集群上。
参见附图3,是本发明实施例提的一种系统架构300。在此架构中执行设备210由一个或多个服务器实现,可选的,与其它计算设备配合,例如:数据存储、路由器、负载均 衡器等设备;执行设备210可以布置在一个物理站点上,或者分布在多个物理站点上。执行设备210可以使用数据存储系统250中的数据,或者调用数据存储系统250中的程序代码实现对象推荐的功能,具体地,将待推荐的对象的信息输入到推荐模型中,推荐模型为每个待推荐对象生成预估分数,然后按照预估分数从高到低的顺序进行排序,按照排序结果向用户推荐该待推荐对象。例如,将排序结果中的前10个对象推荐给用户。
其中,数据存储系统250用于接收和存储训练设备发送的推荐模型的参数,以及用于存储通过推荐模型得到的推荐结果的数据,当然还可能包括该存储系统250正常运行所需的程序代码(或指令)。数据存储系统250可以为部署在执行设备210以外的一个设备或者多个设备构成的分布式存储集群,此时,当执行设备210需要使用存储系统250上的数据时,可以由存储系统250向执行设备210发送该执行设备所需的数据,相应地,该执行设备210接收并存储(或者缓存)该数据。当然数据存储系统250也可以部署在执行设备210内,当部署在执行设备210内时,该分布式存储系统可以包括一个或者多个存储器,可选的,存在多个存储器时,不同的存储器用于存储不同类型的数据,如通过训练设备生成的推荐模型的模型参数和通过推荐模型得到的推荐结果的数据可以分别存储在两个不同的存储器上。
用户可以操作各自的用户设备(例如本地设备301和本地设备302)与执行设备210进行交互。每个本地设备可以表示任何计算设备,例如个人计算机、计算机工作站、智能手机、平板电脑、智能摄像头、智能汽车或其他类型蜂窝电话、媒体消费设备、可穿戴设备、机顶盒、游戏机等。
每个用户的本地设备可以通过任何通信机制/通信标准的通信网络与执行设备210进行交互,通信网络可以是广域网、局域网、点对点连接等方式,或它们的任意组合。
在另一种实现中,执行设备210可以由本地设备实现,例如,本地设备301可以基于推荐模型实现执行设备210的的推荐功能获取用户特征信息并向用户反馈推荐结果,或者为本地设备302的用户提供服务。
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例涉及的相关术语及神经网络等相关概念进行介绍。
1、点击概率(click-throughrate,CTR)
点击概率又可以称为点击率,是指网站或者应用程序上推荐信息(例如,推荐物品)被点击次数和曝光次数之比,点击率通常是推荐系统中衡量推荐系统的重要指标。
2、个性化推荐系统
个性化推荐系统是指根据用户的历史数据(例如本申请实施例中的操作信息),利用机器学习算法进行分析,并以此对新请求进行预测,给出个性化的推荐结果的系统。
3、离线训练(offlinetraining)
离线训练是指在个性化推荐系统中,根据用户的历史数据(例如本申请实施例中的操作信息),对推荐模型参数按照器学习的算法进行迭代更新直至达到设定要求的模块。
4、在线预测(onlineinference)
在线预测是指基于离线训练好的模型,根据用户、物品和上下文的特征预测该用户在当前上下文环境下对推荐物品的喜好程度,预测用户选择推荐物品的概率。
例如,图4A是本申请实施例提供的推荐系统的示意图。如图4A所示,当一个用户进入统,会触发一个推荐的请求,推荐系统会将该请求及其相关信息(例如本申请实施例 中的操作信息)输入到推荐模型,然后预测用户对系统内的物品的选择率。进一步,根据预测的选择率或基于该选择率的某个函数将物品降序排列,即推荐系统可以按顺序将物品展示在不同的位置作为对用户的推荐结果。用户浏览不同的处于位置的物品并发生用户行为,如浏览、选择以及下载等。同时,用户的实际行为会存入日志中作为训练数据,通过离线训练模块不断更新推荐模型的参数,提高模型的预测效果。
例如,用户打开智能终端(例如,手机)中的应用市场即可触发应用市场中的推荐系统。应用市场的推荐系统会根据用户的历史行为日志,例如,用户的历史下载记录、用户选择记录,应用市场的自身特征,比如时间、地点等环境特征信息,预测用户下载推荐的各个候选APP的概率。根据计算的结果,应用市场的推荐系统可以按照预测的概率值大小降序展示候选APP,从而提高候选APP的下载概率。
示例性地,可以将预测的用户选择率较高的APP展示在靠前的推荐位置,将预测的用户选择率较低的APP展示在靠后的推荐位置。
上述推荐模型可以是神经网络模型,下面对本申请实施例可能涉及的神经网络的相关术语和概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以xs(即输入数据)和截距1为输入的运算单元,该运算单元的输出可以为:
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
(2)深度神经网络
深度神经网络(Deep Neural Network,DNN),也称多层神经网络,可以理解为具有很多层隐含层的神经网络,这里的“很多”并没有特别的度量标准。从DNN按不同层的位置划分,DNN内部的神经网络可以分为三类:输入层,隐含层,输出层。一般来说第一层是输入层,最后一层是输出层,中间的层数都是隐含层。层与层之间是全连接的,也就是说,第i层的任意一个神经元一定与第i+1层的任意一个神经元相连。虽然DNN看起来很复杂,但是就每一层的工作来说,其实并不复杂,简单来说就是如下线性关系表达式:y="α"(Wx+b),其中,x是输入向量,y是输出向量,b是偏移向量,W是权重矩阵(也称系数),"α"()是激活函数。每一层仅仅是对输入向量x经过如此简单的操作得到输出向量y。由于DNN层数多,则系数W和偏移向量b的数量也就很多了。这些参数在DNN中的定义如下所述:以系数W为例:假设在一个三层的DNN中,第二层的第4个神经元到第三层的第2个神经元的线性系数定义为w_24^3。上标3代表系数W所在的层数,而下标对应的是输出的第三层索引2和输入的第二层索引4。总结就是:第L-1层的第k个神经元到第L层的第j个神经元的系数定义为W_jk^L。需要注意的是,输入层是没有W参数的。在深度神经网络中,更多的隐含层让网络更能够刻画现实世界 中的复杂情形。理论上而言,参数越多的模型复杂度越高,“容量”也就越大,也就意味着它能完成更复杂的学习任务。训练深度神经网络的也就是学习权重矩阵的过程,其最终目的是得到训练好的深度神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。
(3)损失函数
在训练深度神经网络的过程中,因为希望深度神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为深度神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断的调整,直到深度神经网络能够预测出真正想要的目标值或与真正想要的目标值非常接近的值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么深度神经网络的训练就变成了尽可能缩小这个loss的过程。
(4)反向传播算法
可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始模型中参数的大小,使得模型的误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始模型中的参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的模型参数,例如权重矩阵。
(5)机器学习系统
基于输入数据和标签,通过梯度下降等优化方法训练机器学习模型的参数,最终利用训练得到的模型来完成未知数据的预测。
(6)个性化推荐系统
根据用户的历史数据,利用机器学习算法进行分析和建模,并以此对新的用户请求进行预测,给出个性化的推荐结果的系统。
(7)混合专家:在神经网络中,将每个线性层看做一个专家,多个线性层并行,将其中一个或者若干个专家的输出进行加权平均,并将结果输出到下一层。
(8)计算图:将用户通过深度神经网络框架描述的运算构建成的一个计算的图结构,通常描述整个深度神经网络计算的流程,包括前向、反向传播以及参数更新。
(9)记忆网络:将输入转化为网络里面内在的向量,并将向量保存在记忆矩阵里面。
(10)路由:控制输入数据和某个网络模块映射关系的函数。
(11)持续学习:也称终身学习(Life-long learning)是解决此类问题的研究方向,它的目标是扩展模型适应能力,令模型能够在不同时刻学习不同任务的知识,同时不会遗忘先前任务的特征。
(12)页表:一种数据结构,可以用于记载两种数据之间的映射关系。通常用于将虚拟地址转换为物理地址。分级页表也是页表的一种。页表被存储在存储介质中,页表的基址,也简称页表基址,是指存储该页表的物理地址的起始地址。页表的大小决定这个页表对应的虚拟地址的取值范围。页表中的虚拟地址是使用该页表的实例或者设备的虚拟地 址,用于指示该页表中某个位置(或者说某个表项)的物理地址相对于页表基址的偏移量。而页表中某个位置存储的数据,就是使用这个页表的实例或者设备的物理地址空间中的物理地址。一个页表中包括多个表项,每个表项都可以指示一个虚拟地址与一个物理地址的映射关系,应理解的是,这里所说的表项是个功能性的描述,表项的具体实现方式本申请不做限定,例如一个虚拟地址与一个物理地址的映射关系可能是跨级的,一个虚拟地址与一个物理地址的映射关系也可能是间接的。本申请中的页表具体可以为多级页表。
(13)transformer层
参照图4B,图4B为一种transformer层的架构示意,如图4B所示,神经网络包括嵌入层和至少一个transformer层,至少一个transformer层可以为N个transformer层(N大于0的整数),其中,每个transformer层包括依次相邻的注意力层、加和与归一化(add&norm)层、前馈(feed forward)层和加和与归一化层。在嵌入层,对当前输入进行嵌入处理,得到多个特征向量;在所述注意力层,从所述transformer层的上一层获取P个输入向量,以P个输入向量中的任意的第一输入向量为中心,基于预设的注意力窗口范围内的各个输入向量与该第一输入向量之间的关联度,得到该第一输入向量对应的中间向量,如此确定出P个输入向量对应的P个中间向量;在所述池化层,将所述P个中间向量合并为Q个输出向量,其中至少一个transformer层中最后一个transformer层得到的多个输出向量用作所述当前输入的特征表示。
接下来,结合具体例子对上述各步骤进行具体介绍。
首先,在所述嵌入层,对当前输入进行嵌入处理,得到多个特征向量。
嵌入层可以称为输入嵌入(input embedding)层。当前输入可以为文本输入,例如可以为一段文本,也可以为一个句子。文本可以为中文文本,也可以为英文文本,还可以为其他语言文本。嵌入层在获取当前输入后,可以对该当前输入中各个词进行嵌入处理,可得到各个词的特征向量。在一些实施例中,如图4B所示,所述嵌入层包括输入嵌入层和位置编码(positional encoding)层。在输入嵌入层,可以对当前输入中的各个词进行词嵌入处理,从而得到各个词的词嵌入向量。在位置编码层,可以获取各个词在该当前输入中的位置,进而对各个词的位置生成位置向量。在一些示例中,各个词的位置可以为各个词在该当前输入中的绝对位置。以当前输入为“几号应还花呗”为例,其中的“几”的位置可以表示为第一位,“号”的位置可以表示为第二位,……。在一些示例中,各个词的位置可以为各个词之间的相对位置。仍以当前输入为“几号应还款”为例,其中的“几”的位置可以表示为“号”之前,“号”的位置可以表示为“几”之后、“应”之前,……。当得到当前输入中各个词的词嵌入向量和位置向量时,可以将各个词的位置向量和对应的词嵌入向量进行组合,得到各个词特征向量,即得到该当前输入对应的多个特征向量。多个特征向量可以表示为具有预设维度的嵌入矩阵。可以设定该多个特征向量中的特征向量个数为M,预设维度为H维,则该多个特征向量可以表示为M×H的嵌入矩阵。
其次,从所述第一transformer层的上一层获取P个输入向量,以P个输入向量中的任意的第一输入向量为中心,基于预设的注意力窗口范围内的各个输入向量与该第一输入向量之间的关联度,得到该第一输入向量对应的中间向量,如此确定出P个输入向量对应的P个中间向量。注意力层也可以称为多头注意力(multi-head attention)层。在一个例子中,注意力层可以为固定窗口多头注意力(fixed window multi-head attention)层。
在一些实施例中,第一transformer层可以为上述嵌入层的下一层,P个输入向量为从 嵌入层得到的所述多个特征向量。在一些实施例中,本说明书实施例提供的神经网络中的至少一个transformer层还包括第二transformer层。该第二transformer层为第一自注意力的上一层,则P个输入向量为第二transformer层输出的P个输出向量。在该神经网络中的最后一个transformer层,通过上述步骤的多个输出向量可用作当前输入的特征表示。该特征表示为为当前输入的一种适合计算机处理的特征表示。
(14)注意力机制(attention mechanism)
注意力机制模仿了生物观察行为的内部过程,即一种将内部经验和外部感觉对齐从而增加部分区域的观察精细度的机制,能够利用有限的注意力资源从大量信息中快速筛选出高价值信息。注意力机制可以快速提取稀疏数据的重要特征,因而被广泛用于自然语言处理任务,特别是机器翻译。而自注意力机制(self-attention mechanism)是注意力机制的改进,其减少了对外部信息的依赖,更擅长捕捉数据或特征的内部相关性。注意力机制的本质思想可以改写为如下公式:
其中,Lx=||Source||代表Source的长度,公式含义即将Source中的构成元素想象成是由一系列的数据对构成,此时给定目标Target中的某个元素Query,通过计算Query和各个Key的相似性或者相关性,得到每个Key对应Value的权重系数,然后对Value进行加权求和,即得到了最终的Attention数值。所以本质上Attention机制是对Source中元素的Value值进行加权求和,而Query和Key用来计算对应Value的权重系数。从概念上理解,把Attention可以理解为从大量信息中有选择地筛选出少量重要信息并聚焦到这些重要信息上,忽略大多不重要的信息。聚焦的过程体现在权重系数的计算上,权重越大越聚焦于其对应的Value值上,即权重代表了信息的重要性,而Value是其对应的信息。自注意力机制可以理解为内部Attention(intra attention),Attention机制发生在Target的元素Query和Source中的所有元素之间,自注意力机制指的是在Source内部元素之间或者Target内部元素之间发生的Attention机制,也可以理解为Target=Source这种特殊情况下的注意力计算机制,其具体计算过程是一样的,只是计算对象发生了变化而已。
近年来,随着计算芯片技术和大规模计算集群的快速发展,越来越多的大模型开始出现,千亿甚至万亿级别的大模型成为最近甚至未来一段时间的主流技术趋势。但是,大模型最核心的问题在于,训练和使用成本极其高昂,通常需要数百块,甚至几千块GPU、TPU或者NPU芯片等计算单元组成的超大规模集群,计算数周甚至数个月时间,成本以百万至千万美元计。这个核心问题的另一个问题是,成本如此高昂的模型,如何设计和训练,以充分发挥其价值,并在设计之初,就要为未来可能的未知的使用场景做出准备,因为成本如此高昂的模型,是不可能被一遍一遍的重新训练的,因此需要有某种形式能够保存以前训练的成果,并能够为未来的可能使用场景做准备。
在一种实现方案中,可以将大规模模型划分为多个网络单元,针对于不同的输入样本(例如不同的词向量),设置有对应的网络单元,在使用某一输入样本进行模型训练时,多个网络单元中仅该输入样本对应的网络单元被更新,且更新后的网络单元会被存储起来,以便下一次更新时被调用。
在现有技术中,通常使用计算单元中的内存来存储大模型,计算单元中的内存较小,限制了大规模模型自身的大小。
为了解决上述问题,本申请提供了一种数据处理方法。
参照图5,图5为本申请实施例提供的一种数据处理方法的实施例示意,如图5示出的那样,本申请实施例提供的一种数据处理方法,包括:
501、根据目标映射关系,确定目标词向量token对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址,所述存储地址对应的存储空间位于计算单元之外的存储空间。
本申请实施例中,步骤501的执行主体可以为终端设备,终端设备可以为便携式移动设备,例如但不限于移动或便携式计算设备(如智能手机)、个人计算机、服务器计算机、手持式设备(例如平板)或膝上型设备、多处理器系统、游戏控制台或控制器、基于微处理器的系统、机顶盒、可编程消费电子产品、移动电话、具有可穿戴或配件形状因子(例如,手表、眼镜、头戴式耳机或耳塞)的移动计算和/或通信设备、网络PC、小型计算机、大型计算机、包括上面的系统或设备中的任何一种的分布式计算环境等等。
本申请实施例中,步骤501的执行主体可以为云侧的服务器。
为了方便描述,以下不对执行主体的形态进行区分,都描述为训练设备。
在一种可能的实现中,所述目标网络单元为前向传播网络FFN,目标网络单元在本申请实施例中也可以称之为专家网络。
在一种可能的实现中,可以预先构建不同训练样本(词向量token)和目标网络单元之间的映射关系(或者可以称之为多值映射表或者多级映射表),大规模网络在针对不同训练样本(词向量token)进行模型训练时,可以将大规模网络中目标网络单元所在位置的网络结构设置成映射关系中所指示的网络单元或者网络单元的组合。
其中,目标映射关系可以包括第一目标映射关系和第二目标映射关系,第一目标映射关系可以指示词向量和网络单元之间的映射关系,具体可以是词向量和网络单元对应的标识ID之间的映射关系。标识:用于将一种或者一个事物与其他同类或不同类的事物做区分。比如,节点的标识,网络的标识,网卡的标识。标识可以是名称,编号,也可以是以某个有区分性的特征作为标识,例如用种类标识。本申请对各种标识的实现不做限制,只要可以做出区分即可。
在现有技术中,通过散列hash的方式来构建训练样本(词向量token)和网络单元之间的映射关系,由于散列hash中一个训练样本仅能对应唯一一个网络单元,且由于散列hash中存在数值范围限制,随着训练样本的增大,可能会出现大量不同的训练样本对应于同一个网络单元的情况,使得训练后的模型的精度受到影响。本申请中,通过映射表的方式来记载训练样本(词向量token)和网络单元之间的映射关系,可以实现一个训练样本对应多个网络单元,且由于没有数值范围限制,不会出现大量不同的训练样本对应于同一个网络单元的情况,进而可以增大训练后的模型的精度。
在一种可能的实现中,可以将大规模网络(例如盘古alpha或者Transformer中的FFN)替换为图6中的存储单元,即若干个并行排列的expert。这些专家的分组是由多值映射表决定的,每个多值映射表许多由键值对(key-value)构成,可选的,词表中的词(token)构成多值映射表的键(key),值(value)就是专家的ID号,比如图中的E1到E11。构建好这个多值映射表后,在训练过程中,控制模块就可以根据数据单元的数据动态从存储单元中提取需要计算的计算单元高效计算。可选的,也可以根据loss值决定是否动态扩展存储单元的专家模块。
关于上述多值映射表的构建:
分组是在构建多值映射表的时候由用户决定的,例如,可以构建如下图7的多射映射表。用户先确定需要建模的分组数量G,以及每个分组初始化的专家个数K_g,对词表的Token来说,属于哪个或哪些分组,是由用户自己的决定的,例如,用户可以根据token所属的语言分组,中文为一个专家组,英文为另一个专家组,有些token属于两个专家组,比如一些阿拉伯数字。分好分组以后,每个分组的专家数也是固定的,那么属于这个专家组的token就可以通过某个函数进行分配映射的专家,比如可以随机,也可以顺序取余。在训练开始之前,需要构建好一个初始版本的多值映射表,然后启动训练。
在一种可能的实现中,在一种可能的实现中,所述计算单元为图形处理器GPU、张量处理器TPU或者神经网络处理器NPU。
在一种可能的实现中,所述存储地址对应的存储空间位于内存、网络存储器或者硬盘。
在一种可能的实现中,所述目标映射关系包括第一目标映射关系,所述第一目标映射关系指示多个词向量以及每个词向量对应的一个或多个网络单元,所述第一目标映射关系具体为映射表。
在一种可能的实现中,所述目标映射关系还可以包括第三目标映射关系,所述第三目标映射关系指示每个网络单元的存储位置。该存储位置可以通过存储空间对应的物理地址或者虚拟地址来表示,基于该虚拟地址可以唯一确定对应的物理地址,例如,地址可以包括起始地址以及偏置。
由于大规模模型中的目标网络单元存储在计算单元之外的存储位置,在当前的训练样本为对应的词向量时,从计算单元之外的存储位置中提取对应的一个或多个目标网络单元,由于计算单元之外的存储位置的存储空间可以设置的较大,通过存算分离,可以提高大规模模型自身的大小,并增加大规模模型的可扩展性和灵活度。
在一种可能的实现中,上述目标映射关系可以被用户修改。
具体的,在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,还可以接收到用户针对于第二目标映射关系的修改信息,其中,所述第二目标映射关系包括多个词向量以及每个词向量对应的网络单元;根据所述修改信息,修改第二目标映射关系,以得到所述目标映射关系。
修改信息可以用于修改第二目标映射关系中某个词向量所对应的网络单元进行修改,或者是对词向量与网络单元的对应关系进行修改。
在一种可能的实现中,所述修改信息用于指示如下的至少一种:对所述第二目标映射关系中至少一个词向量对应的网络单元的删除、替换或者增加;对所述第二目标映射关系中包括的映射关系的删除、替换或者增加,所述映射关系为词向量以及词向量对应的网络单元。
此外,系统还可以基于模型训练的情况自行进行映射关系的修改。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,可以在通过所述目标词向量对所述神经网络执行训练过程中,基于训练损失的下降程度低于阈值(在训练损失的下降程度较低时,可以表示模型当前的性能无法再继续提高了,这时候可以通过增加网络单元来改变神经网络的结构,使得训练的损失可以继续下降),对第二目标映射关系中所述目标词向量对应的网络单元进行增加,以得到所述目标映射关系。
在一种可能的实现中,可以通过确定应映射关系和大容量的映射关系数据结构,可以支撑本实施例进行记忆网络的容量扩增和删减,并在同时取得持续学习的效果。持续学习指的是模型能够在学习了一段时间的数据后,继续学习新的数据,能够避免之前学到的知识被遗忘,同时能够学习到新的知识的技术。本实施例的一个可选的流程如下:
如图9所示,步骤如下:
步骤1、训练从配置文件中读取是否修改映射表,如果有修改,则按照配置修改多值映射表和相应的存储单元。这种配置是非常灵活的,可以是同一个专家组的扩充,如图扩充专家组的E4,也可以是扩充新的专家组,如图中扩充专家组3。然后继续训练。
步骤2、读取配置文件中的扩增阈值K,针对每个专家组的loss,并时刻记录loss的最小值,如果最小值已经连续K步没有更新,则认为模型的loss已经不再降了,进入步骤3。否则就继续训练。
步骤3、满足步骤2条件后,针对不降的loss对应的专家组,修改多值映射表,假设原始专家组为M个专家,则按照某种规则将多值映射表中1/M个token映射的专家,添加一个新的映射专家,如图中的E4。其中这个规则可以是最高频的1/M个token,或者是随机选取1/M个token。
步骤4、框架实时调整计算图,并分配新的存储空间给新增添的专家E4,并继续训练。
通过上述方式,可以允许模型的记忆模块进行伸缩,以针对不同场景,扩展和裁剪模型容量。
502、从所述存储地址对应的存储空间中获取所述一个或多个目标网络单元;所述一个或多个目标网络单元用于构建神经网络。
在一种可能的实现中,在获取到存储地址后,可以从存储地址对应的存储空间中获取所述一个或多个目标网络单元,并利用该一个或多个目标网络单元进行神经网络的构建,具体的,一个或多个目标网络单元可以用于进行目标网络单元对应位置的网络结构的构建。
具体流程的一个示意可以如下图8所示,主要由以下步骤组成:
步骤1:当一个迭代的训练开始的时候,控制模块读取本次迭代的数据。
步骤2:根据上一步读取的数据,在多值映射表中,以数据为key,查找对应的专家的编号。
步骤3:分两步,先根据上一步查找到的专家的编号,找到对应专家的内存地址。然后3.2,根据找到的内存地址,将需要使用的专家提取出来,或者将不使用的专家冻结。这种提取可以是在新的内存空间,构建计算子图,将存储单元中对应的专家拷贝到新的计算空间,也可以是在存储单元中,用虚拟的内存映射管理存储单元中对应的专家做为计算单元。而这种冻结,会将冻结操从计算图上传播给对应的反向计算节点和优化器更新节点,确保在本轮中不需要计算的专家,正向反向和优化器更新都不需要参与计算。
503、根据所述目标词向量,通过所述计算单元执行所述神经网络对应的训练过程。
在一种可能的实现中,所述通过所述计算单元执行所述目标神经网络对应的训练过程用于得到更新后的目标神经网络,所述更新后的目标神经网络包括更新后的所述一个或多个目标网络单元,根据所述更新后的所述一个或多个目标网络单元,更新所述存储地址对应的存储空间中的数据,以便下一次调用。
参照图8,本申请实施例的一个可选实现步骤可以包括:
步骤4:利用上一步构建的计算单元,将步骤1读入的数据和对应的专家做实际的计算,前向转播算出loss,并做反向计算,以及优化器更新专家参数。
步骤5:将计算单元中更新的专家参数,和存储单元中对应的专家参数同步。
上述步骤的思想在于,通过内存管理,将稀疏化的专家记忆单元,也就是存储单元中的专家找出来,并确保只计算这一部分激活的专家,其余不需要计算的不参与任何前向,反向,优化器更新的计算,保证稀疏化的记忆网络在计算中没有冗余,从而提到训练效率。
在一种可能的实现中,所述所述目标映射关系包括多个词单元以及每个词单元对应的网络单元,还可以根据收敛后所述神经网络,从所述目标映射关系中包括的多个词单元中确定部分词单元对应的网络单元,所述收敛后所述神经网络中所述部分词单元对应的网络单元用于构建目标神经网络;所述目标神经网络用于进行模型推理。
上述过程可以称之为子模型的抽取,示例性的流程可以参照图10所示。
本申请实施例提出了一种新型的可伸缩的记忆网络设计,同其高效训练算法。保证能够在高效训练由这样的网络模块构成的大模型的同时,使得模型通过记忆模块的伸缩,获得持续学习能力,保证模型一直处于最新的知识状态。系统架构如下图11所示:
一是多值映射表(multi-value mapping)。该模块是本专利可行的数据结构基础。和上面相关工作中提到的散列不同,映射是一种直接存储的键值对关系,不需要通过散列函数去映射到一个固定的索引范围,因此没有碰撞问题。这就决定了用映射数据结构构建的关系,不会丢失关键信息。而这里采用多值映射,就是构建一个键值和集合的映射对,集合中可以是任意多的元素,这样就保证了我们的映射关系不仅仅是单一的。本专利中的多值映射表,支持多种操作,如查找,插入和删除等修改。这些操作和下面将要描述的控制模块配合,实现了我们专利描述的训练算法和终身学习算法。
二是控制模块。控制模块如下图虚线控制模块所示,控制模块是本系统的核心,具体有两个主要功能:
一是为完成终身学习能力设计的功能,控制模块从损失或者某个度量函数获得信息后,如果判断需要增加记忆网络的数量,算法走入“是”分支,存储控制单元首先会修改多值映射表,增添或者删除映射内的键值对,然后存储控制单元会在存储子图部分开辟或者释放对应的内存空间。
二是为了实现高性能训练设计的功能,如果判断为否,也就是说不需要进行记忆网络的增添和删除,算法将会走到“否”分支。在这个分支,控制模块的路由能够通过读取当前数据单元的数据,查询多值映射表中的映射关系,得知本次需要计算的记忆网络的编号,并根据这个查询结果,计算控制模块将需要计算的子图通过某种方式提取出来,可以是拉取,也可以是构建一个新的子图,也可以是在存储子图的本地,对不计算的部分进行冻结,确保只计算需要计算的部分。并且这个操作将会传播给计算图的所有相关计算部分,在大规模分布式场景中,将不进行对应的梯度传输,从而大大减少整个模型的计算量和通信量。
三是记忆网络模块。就是图中的存储单元和计算单元,记忆模块由线性网络构成,一般有一个以上的线性网络构成,每个线性网络有一个编号,比如图中的A,B,C,D,用于区分不同的线性网络,这个编号也是多值映射表中的键值对中的值的元素,控制装置可以通过这个值找到对应的记忆网络的地址,并对对应的网络进行提取,拷贝,删除,新增等操作。每个网络记忆了当前状态训练实体对应的本层特征。
四是数据单元。可以是训练数据,也可以是某种经过编码的中间结果。
接下来从装置的角度介绍本申请实施例提供的一种数据处理装置,参照图12,图12为本申请实施例提供的一种数据处理装置的结构示意,如图12所示,本申请实施例提供的一种数据处理装置1200包括:
处理模块1201,用于根据目标映射关系,确定目标词向量token对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址,所述存储地址对应的存储空间位于计算单元之外的存储空间;
从所述存储地址对应的存储空间中获取所述一个或多个目标网络单元;所述一个或多个目标网络单元用于构建神经网络;
其中,关于处理模块1201的具体描述,可以参照上述实施例中步骤501和步骤502的介绍,这里不再赘述。
模型训练模块1202,用于根据所述目标词向量,通过所述计算单元执行所述神经网络对应的训练过程。
其中,关于模型训练模块1202的具体描述,可以参照上述实施例中步骤503的介绍,这里不再赘述。
在一种可能的实现中,所述目标网络单元为前向传播网络FFN。
在一种可能的实现中,所述计算单元为图形处理器GPU、张量处理器TPU或者神经网络处理器NPU。
在一种可能的实现中,所述存储地址对应的存储空间位于内存、网络存储器或者硬盘。
在一种可能的实现中,所述目标映射关系包括第一目标映射关系,所述第一目标映射关系指示多个词向量以及每个词向量对应的一个或多个网络单元,所述第一目标映射关系具体为映射表。
在一种可能的实现中,所述通过所述计算单元执行所述目标神经网络对应的训练过程用于得到更新后的目标神经网络,所述更新后的目标神经网络包括更新后的所述一个或多个目标网络单元,所述处理模块,还用于:
根据所述更新后的所述一个或多个目标网络单元,更新所述存储地址对应的存储空间中的数据。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述处理模块,还用于:
接收到用户针对于第二目标映射关系的修改信息,其中,所述第二目标映射关系包括多个词向量以及每个词向量对应的网络单元;
根据所述修改信息,修改第二目标映射关系,以得到所述目标映射关系。
在一种可能的实现中,所述修改信息用于指示如下的至少一种:
对所述第二目标映射关系中至少一个词向量对应的网络单元的删除、替换或者增加;
对所述第二目标映射关系中包括的映射关系的删除、替换或者增加,所述映射关系为词向量以及词向量对应的网络单元。
在一种可能的实现中,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述处理模块,还用于:
在通过所述目标词向量对所述神经网络执行训练过程中,基于训练损失的下降程度低 于阈值,对第二目标映射关系中所述目标词向量对应的网络单元进行增加,以得到所述目标映射关系。
在一种可能的实现中,所述所述目标映射关系包括多个词单元以及每个词单元对应的网络单元,所述处理模块,还用于:
根据收敛后所述神经网络,从所述目标映射关系中包括的多个词单元中确定部分词单元对应的网络单元,所述收敛后所述神经网络中所述部分词单元对应的网络单元用于构建目标神经网络;所述目标神经网络用于进行模型推理。
接下来介绍本申请实施例提供的一种执行设备,请参阅图13,图13为本申请实施例提供的执行设备的一种结构示意图,执行设备1300具体可以表现为手机、平板、笔记本电脑、智能穿戴设备、服务器等,此处不做限定。其中,执行设备1300实现图10对应实施例中图像处理方法的功能。具体的,执行设备1300包括:接收器1301、发射器1302、处理器1303和存储器1304(其中执行设备1300中的处理器1303的数量可以一个或多个),其中,处理器1303可以包括应用处理器13031和通信处理器13032。在本申请的一些实施例中,接收器1301、发射器1302、处理器1303和存储器1304可通过总线或其它方式连接。
存储器1304可以包括只读存储器和随机存取存储器,并向处理器1303提供指令和数据。存储器1304的一部分还可以包括非易失性随机存取存储器(non-volatile random access memory,NVRAM)。存储器1304存储有处理器和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。
处理器1303控制执行设备的操作。具体的应用中,执行设备的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都称为总线系统。
上述本申请实施例揭示的方法可以应用于处理器1303中,或者由处理器1303实现。处理器1303可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器1303中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器1303可以是通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器、以及视觉处理器(vision processing unit,VPU)、张量处理器(tensor processing unit,TPU)等适用于AI运算的处理器,还可进一步包括专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。该处理器1303可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1304,处理器1303读取存储器1304中的信息,结合其硬件完成上述实施例中步骤501至步骤503的步骤。
接收器1301可用于接收输入的数字或字符信息,以及产生与执行设备的相关设置以及功能控制有关的信号输入。发射器1302可用于通过第一接口输出数字或字符信息;发 射器1302还可用于通过第一接口向磁盘组发送指令,以修改磁盘组中的数据;发射器1302还可以包括显示屏等显示设备。
本申请实施例还提供了一种训练设备,请参阅图14,图14是本申请实施例提供的训练设备一种结构示意图,具体的,训练设备1400可以为上述实施例介绍的数据处理装置,训练设备1400由一个或多个服务器实现,训练设备1400可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)1414(例如,一个或一个以上处理器)和存储器1432,一个或一个以上存储应用程序1442或数据1444的存储介质1430(例如一个或一个以上海量存储设备)。其中,存储器1432和存储介质1430可以是短暂存储或持久存储。存储在存储介质1430的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对训练设备中的一系列指令操作。更进一步地,中央处理器1414可以设置为与存储介质1430通信,在训练设备1400上执行存储介质1430中的一系列指令操作。
训练设备1400还可以包括一个或一个以上电源1426,一个或一个以上有线或无线网络接口1450,一个或一个以上输入输出接口1458;或,一个或一个以上操作系统1441,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。
本申请实施例中还提供一种包括计算机可读指令的计算机程序产品,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例中还提供一种计算机可读存储介质,该计算机可读存储介质中存储有用于进行信号处理的程序,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例提供的执行设备、训练设备或终端设备具体可以为芯片,芯片包括:处理单元和通信单元,所述处理单元例如可以是处理器,所述通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使执行设备内的芯片执行上述实施例描述的模型训练方法,或者,以使训练设备内的芯片执行上述实施例中与模型训练相关的步骤。可选地,所述存储单元为所述芯片内的存储单元,如寄存器、缓存等,所述存储单元还可以是所述无线接入设备端内的位于所述芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。
具体的,请参阅图15,图15为本申请实施例提供的芯片的一种结构示意图,所述芯片可以表现为神经网络处理器NPU 1500,NPU 1500作为协处理器挂载到主CPU(Host CPU)上,由Host CPU分配任务。NPU的核心部分为运算电路1503,通过控制器1504控制运算电路1503提取存储器中的矩阵数据并进行乘法运算。
在一些实现中,运算电路1503内部包括多个处理单元(Process Engine,PE)。在一些实现中,运算电路1503是二维脉动阵列。运算电路1503还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路1503是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器1502中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器1501 中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)1508中。
统一存储器1506用于存放输入数据以及输出数据。权重数据直接通过存储单元访问控制器(Direct Memory Access Controller,DMAC)1505,DMAC被搬运到权重存储器1502中。输入数据也通过DMAC被搬运到统一存储器1506中。
BIU为Bus Interface Unit即,总线接口单元1510,用于AXI总线与DMAC和取指存储器(Instruction Fetch Buffer,IFB)1509的交互。
总线接口单元1510(Bus Interface Unit,简称BIU),用于取指存储器1509从外部存储器获取指令,还用于存储单元访问控制器1505从外部存储器获取输入矩阵A或者权重矩阵B的原数据。
DMAC主要用于将外部存储器DDR中的输入数据搬运到统一存储器1506或将权重数据搬运到权重存储器1502中或将输入数据数据搬运到输入存储器1501中。
向量计算单元1507包括多个运算处理单元,在需要的情况下,对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。主要用于神经网络中非卷积/全连接层网络计算,如Batch Normalization(批归一化),像素级求和,对特征平面进行上采样等。
在一些实现中,向量计算单元1507能将经处理的输出的向量存储到统一存储器1506。例如,向量计算单元1507可以将线性函数;或,非线性函数应用到运算电路1503的输出,例如对卷积层提取的特征平面进行线性插值,再例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元1507生成归一化的值、像素级求和的值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路1503的激活输入,例如用于在神经网络中的后续层中的使用。
控制器1504连接的取指存储器(instruction fetch buffer)1509,用于存储控制器1504使用的指令;
统一存储器1506,输入存储器1501,权重存储器1502以及取指存储器1509均为On-Chip存储器。外部存储器私有于该NPU硬件架构。
其中,上述任一处提到的处理器,可以是一个通用中央处理器,微处理器,ASIC,或一个或多个用于控制上述程序执行的集成电路。
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术 做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。
进一步,本申请实施例提供的图像分类方法能够应用在图片检索、相册管理、平安城市、人机交互以及其他需要进行图像分类或者图像识别的场景。应理解,本申请实施例中的图像可以为静态图像(或称为静态画面)或动态图像(或称为动态画面),例如,本申请中的图像可以为视频或动态图片,或者,本申请中的图像也可以为静态图片或照片。为了便于描述,本申请在下述实施例中将静态图像或动态图像统一称为图像。
本申请实施例的图像分类方法可以具体应用到相册分类和拍照识别场景中,下面对这两种场景进行详细的介绍。
相册分类:
用户在手机和云盘上存储了大量图片,按照类别对相册进行分类管理能提高用户的体验。利用本申请实施例的图像分类方法对相册中的图片进行分类,能够得到按照类别进行排列或者存储的相册。本申请实施例的图片分类方法可以方便用户对不同的物体类别进行分类管理,从而方便用户的查找,能够节省用户的管理时间,提高相册管理的效率。
具体地,在采用本申请实施例的图像分类方法进行相册分类时,可以利用本申请提供的神经网络,先提取相册中图片的图片特征,然后再根据提取到的图片特征对相册中的图片进行分类,得到图片的分类结果,接下来,再根据图片的分类结果对相册中的图片进行分类,得到按照图片类别进行排列的相册。其中,在根据图片类别对相册中的图片进行排列时,可以将属于同一类的图片排列在一行或者一行。例如,在最终得到的相册中,第一行的图片都属于飞机,第二行的图片都属于汽车。
拍照识物:
用户在拍照时,可以利用本申请实施例的图像分类方法对拍到的照片进行处理,能够自动识别出被拍物体的类别,例如,可以自动识别出被拍物体是花卉、动物等。进一步地,利用本申请实施例的图像分类方法可以对拍照得到的物体进行识别,识别出该物体所属的类别,例如,用户拍照得到的照片中包括共享单车,利用本申请实施例的图像分类方法能 够对共享单车进行识别,识别出该物体属于自行车,进一步地,还可以显示自行车的相关信息。
应理解,上文介绍的相册分类和拍照识物只是本申请实施例的图像分类方法所应用的两个具体场景,本申请实施例的图像分类方法在应用时并不限于上述两个场景,本申请实施例的图像分类方法能够应用到任何需要进行图像分类或者图像识别的场景中。
本申请实施例中的图像分类方法中使用了一种新的神经网络模型,该模型也可以类似地应用于其他使用神经网络的领域,例如,人脸识别、语音识别、目标检测、机器翻译及语义分割等。
本申请实施例涉及了大量神经网络的相关应用,为了更好地理解本申请实施例的方案,下面先对本申请实施例可能涉及的神经网络的相关术语和概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以xs和截距1为输入的运算单元,该运算单元的输出可以如公式(1-1)所示:
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
(2)深度神经网络
深度神经网络(deep neural network,DNN),也称多层神经网络,可以理解为具有多层隐含层的神经网络。按照不同层的位置对DNN进行划分,DNN内部的神经网络可以分为三类:输入层,隐含层,输出层。一般来说第一层是输入层,最后一层是输出层,中间的层数都是隐含层。层与层之间是全连接的,也就是说,第i层的任意一个神经元一定与第i+1层的任意一个神经元相连。
虽然DNN看起来很复杂,但是就每一层的工作来说,其实并不复杂,简单来说就是如下线性关系表达式:其中,是输入向量,是输出向量,是偏移向量,W是权重矩阵(也称系数),α()是激活函数。每一层仅仅是对输入向量经过如此简单的操作得到输出向量由于DNN层数多,系数W和偏移向量的数量也比较多。这些参数在DNN中的定义如下所述:以系数W为例:假设在一个三层的DNN中,第二层的第4个神经元到第三层的第2个神经元的线性系数定义为上标3代表系数W所在的层数,而下标对应的是输出的第三层索引2和输入的第二层索引4。
综上,第L-1层的第k个神经元到第L层的第j个神经元的系数定义为
需要注意的是,输入层是没有W参数的。在深度神经网络中,更多的隐含层让网络更能够刻画现实世界中的复杂情形。理论上而言,参数越多的模型复杂度越高,“容量”也就越大,也就意味着它能完成更复杂的学习任务。训练深度神经网络的也就是学习权重矩阵的过程,其最终目的是得到训练好的深度神经网络的所有层的权重矩阵(由很多层的向量 W形成的权重矩阵)。
(3)卷积神经网络
卷积神经网络(convolutional neuron network,CNN)是一种带有卷积结构的深度神经网络。卷积神经网络包含了一个由卷积层和子采样层构成的特征抽取器,该特征抽取器可以看作是滤波器。卷积层是指卷积神经网络中对输入信号进行卷积处理的神经元层。在卷积神经网络的卷积层中,一个神经元可以只与部分邻层神经元连接。一个卷积层中,通常包含若干个特征平面,每个特征平面可以由一些矩形排列的神经单元组成。同一特征平面的神经单元共享权重,这里共享的权重就是卷积核。共享权重可以理解为提取图像信息的方式与位置无关。卷积核可以以随机大小的矩阵的形式初始化,在卷积神经网络的训练过程中卷积核可以通过学习得到合理的权重。另外,共享权重带来的直接好处是减少卷积神经网络各层之间的连接,同时又降低了过拟合的风险。
(4)循环神经网络(recurrent neural networks,RNN)是用来处理序列数据的。在传统的神经网络模型中,是从输入层到隐含层再到输出层,层与层之间是全连接的,而对于每一层层内之间的各个节点是无连接的。这种普通的神经网络虽然解决了很多难题,但是却仍然对很多问题无能无力。例如,你要预测句子的下一个单词是什么,一般需要用到前面的单词,因为一个句子中前后单词并不是独立的。RNN之所以称为循环神经网路,即一个序列当前的输出与前面的输出也有关。具体的表现形式为网络会对前面的信息进行记忆并应用于当前输出的计算中,即隐含层本层之间的节点不再无连接而是有连接的,并且隐含层的输入不仅包括输入层的输出还包括上一时刻隐含层的输出。理论上,RNN能够对任何长度的序列数据进行处理。对于RNN的训练和对传统的CNN或DNN的训练一样。
既然已经有了卷积神经网络,为什么还要循环神经网络?原因很简单,在卷积神经网络中,有一个前提假设是:元素之间是相互独立的,输入与输出也是独立的,比如猫和狗。但现实世界中,很多元素都是相互连接的,比如股票随时间的变化,再比如一个人说了:我喜欢旅游,其中最喜欢的地方是云南,以后有机会一定要去。这里填空,人类应该都知道是填“云南”。因为人类会根据上下文的内容进行推断,但如何让机器做到这一步?RNN就应运而生了。RNN旨在让机器像人一样拥有记忆的能力。因此,RNN的输出就需要依赖当前的输入信息和历史的记忆信息。
(5)损失函数
在训练深度神经网络的过程中,因为希望深度神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为深度神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断地调整,直到深度神经网络能够预测出真正想要的目标值或与真正想要的目标值非常接近的值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么深度神经网络的训练就变成了尽可能缩小这个loss的过程。
(6)反向传播算法
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始 的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。
(7)像素值
图像的像素值可以是一个红绿蓝(RGB)颜色值,像素值可以是表示颜色的长整数。例如,像素值为256*Red+100*Green+76Blue,其中,Blue代表蓝色分量,Green代表绿色分量,Red代表红色分量。各个颜色分量中,数值越小,亮度越低,数值越大,亮度越高。对于灰度图像来说,像素值可以是灰度值。
如图16所示,本申请实施例提供了一种系统架构100。在图16中,数据采集设备160用于采集训练数据。针对本申请实施例的图像分类方法来说,训练数据可以包括训练图像以及训练图像对应的分类结果,其中,训练图像的分类结果可以是人工预先标注的结果。
在采集到训练数据之后,数据采集设备160将这些训练数据存入数据库130,训练设备120基于数据库130中维护的训练数据训练得到目标模型/规则101。
下面对训练设备120基于训练数据得到目标模型/规则101进行描述,训练设备120对输入的原始图像进行处理,将输出的图像与原始图像进行对比,直到训练设备120输出的图像与原始图像的差值小于一定的阈值,从而完成目标模型/规则101的训练。
上述目标模型/规则101能够用于实现本申请实施例的图像分类方法,即,将待处理图像通过相关预处理后输入该目标模型/规则101,即可得到图像的分类结果。本申请实施例中的目标模型/规则101具体可以为神经网络。需要说明的是,在实际的应用中,所述数据库130中维护的训练数据不一定都来自于数据采集设备160的采集,也有可能是从其他设备接收得到的。另外需要说明的是,训练设备120也不一定完全基于数据库130维护的训练数据进行目标模型/规则101的训练,也有可能从云端或其他地方获取训练数据进行模型训练,上述描述不应该作为对本申请实施例的限定。
根据训练设备120训练得到的目标模型/规则101可以应用于不同的系统或设备中,如应用于图16所示的执行设备110,所述执行设备110可以是终端,如手机终端,平板电脑,笔记本电脑,增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR),车载终端等,还可以是服务器或者云端设备等。在图16中,执行设备110配置输入/输出(input/output,I/O)接口112,用于与外部设备进行数据交互,用户可以通过客户设备140向I/O接口112输入数据,所述输入数据在本申请实施例中可以包括:客户设备输入的待处理图像。
预处理模块113和预处理模块114用于根据I/O接口112接收到的输入数据(如待处理图像)进行预处理,在本申请实施例中,也可以没有预处理模块113和预处理模块114(也可以只有其中的一个预处理模块),而直接采用计算模块111对输入数据进行处理。
在执行设备110对输入数据进行预处理,或者在执行设备110的计算模块111执行计算等相关的处理过程中,执行设备110可以调用数据存储系统150中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统150中。
最后,I/O接口112将处理结果,如上述得到的待处理图像的分类结果返回给客户设备140,从而提供给用户。
值得说明的是,训练设备120可以针对不同的目标或称不同的任务,基于不同的训练 数据生成相应的目标模型/规则101,该相应的目标模型/规则101即可以用于实现上述目标或完成上述任务,从而为用户提供所需的结果。
在图16所示情况下,用户可以手动给定输入数据,该手动给定可以通过I/O接口112提供的界面进行操作。另一种情况下,客户设备140可以自动地向I/O接口112发送输入数据,如果要求客户设备140自动发送输入数据需要获得用户的授权,则用户可以在客户设备140中设置相应权限。用户可以在客户设备140查看执行设备110输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备140也可以作为数据采集端,采集如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果作为新的样本数据,并存入数据库130。当然,也可以不经过客户设备140进行采集,而是由I/O接口112直接将如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果,作为新的样本数据存入数据库130。
值得注意的是,图16仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图16中,数据存储系统150相对执行设备110是外部存储器,在其它情况下,也可以将数据存储系统150置于执行设备110中。
如图16所示,根据训练设备120训练得到目标模型/规则101,该目标模型/规则101在本申请实施例中可以是本申请中的神经网络,具体的,本申请实施例提供的神经网络可以CNN,深度卷积神经网络(deep convolutional neural networks,DCNN),循环神经网络(recurrent neural network,RNNS)等等。
由于CNN是一种非常常见的神经网络,下面结合图17重点对CNN的结构进行详细的介绍。如上文的基础概念介绍所述,卷积神经网络是一种带有卷积结构的深度神经网络,是一种深度学习(deep learning)架构,深度学习架构是指通过机器学习的算法,在不同的抽象层级上进行多个层次的学习。作为一种深度学习架构,CNN是一种前馈(feed-forward)人工神经网络,该前馈人工神经网络中的各个神经元可以对输入其中的图像作出响应。
如图17所示,卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及神经网络层230。下面对这些层的相关内容做详细介绍。
卷积层/池化层220:
卷积层:
如图17所示卷积层/池化层220可以包括如示例221-226层,举例来说:在一种实现方式中,221层为卷积层,222层为池化层,223层为卷积层,224层为池化层,225为卷积层,226为池化层;在另一种实现方式中,221、222为卷积层,223为池化层,224、225为卷积层,226为池化层。即卷积层的输出可以作为随后的池化层的输入,也可以作为另一个卷积层的输入以继续进行卷积操作。
下面将以卷积层221为例,介绍一层卷积层的内部工作原理。
卷积层221可以包括很多个卷积算子,卷积算子也称为核,其在图像处理中的作用相当于一个从输入图像矩阵中提取特定信息的过滤器,卷积算子本质上可以是一个权重矩阵,这个权重矩阵通常被预先定义,在对图像进行卷积操作的过程中,权重矩阵通常在输入图像上沿着水平方向一个像素接着一个像素(或两个像素接着两个像素……这取决于步长stride的取值)的进行处理,从而完成从图像中提取特定特征的工作。该权重矩阵的大 小应该与图像的大小相关,需要注意的是,权重矩阵的纵深维度(depth dimension)和输入图像的纵深维度是相同的,在进行卷积运算的过程中,权重矩阵会延伸到输入图像的整个深度。因此,和一个单一的权重矩阵进行卷积会产生一个单一纵深维度的卷积化输出,但是大多数情况下不使用单一权重矩阵,而是应用多个尺寸(行×列)相同的权重矩阵,即多个同型矩阵。每个权重矩阵的输出被堆叠起来形成卷积图像的纵深维度,这里的维度可以理解为由上面所述的“多个”来决定。不同的权重矩阵可以用来提取图像中不同的特征,例如一个权重矩阵用来提取图像边缘信息,另一个权重矩阵用来提取图像的特定颜色,又一个权重矩阵用来对图像中不需要的噪点进行模糊化等。该多个权重矩阵尺寸(行×列)相同,经过该多个尺寸相同的权重矩阵提取后的特征图的尺寸也相同,再将提取到的多个尺寸相同的特征图合并形成卷积运算的输出。
这些权重矩阵中的权重值在实际应用中需要经过大量的训练得到,通过训练得到的权重值形成的各个权重矩阵可以用来从输入图像中提取信息,从而使得卷积神经网络200进行正确的预测。
当卷积神经网络200有多个卷积层的时候,初始的卷积层(例如221)往往提取较多的一般特征,该一般特征也可以称之为低级别的特征;随着卷积神经网络200深度的加深,越往后的卷积层(例如226)提取到的特征越来越复杂,比如高级别的语义之类的特征,语义越高的特征越适用于待解决的问题。
池化层/池化层220:
由于常常需要减少训练参数的数量,因此卷积层之后常常需要周期性的引入池化层,在如图17中220所示例的221-226各层,可以是一层卷积层后面跟一层池化层,也可以是多层卷积层后面接一层或多层池化层。在图像处理过程中,池化层的唯一目的就是减少图像的空间大小。池化层可以包括平均池化算子和/或最大池化算子,以用于对输入图像进行采样得到较小尺寸的图像。平均池化算子可以在特定范围内对图像中的像素值进行计算产生平均值作为平均池化的结果。最大池化算子可以在特定范围内取该范围内值最大的像素作为最大池化的结果。另外,就像卷积层中用权重矩阵的大小应该与图像尺寸相关一样,池化层中的运算符也应该与图像的大小相关。通过池化层处理后输出的图像尺寸可以小于输入池化层的图像的尺寸,池化层输出的图像中每个像素点表示输入池化层的图像的对应子区域的平均值或最大值。
神经网络层230:
在经过卷积层/池化层220的处理后,卷积神经网络200还不足以输出所需要的输出信息。因为如前所述,卷积层/池化层220只会提取特征,并减少输入图像带来的参数。然而为了生成最终的输出信息(所需要的类信息或其他相关信息),卷积神经网络200需要利用神经网络层230来生成一个或者一组所需要的类的数量的输出。因此,在神经网络层230中可以包括多层隐含层(如图17所示的231、232至23n)以及输出层240,该多层隐含层中所包含的参数可以根据具体的任务类型的相关训练数据进行预先训练得到,例如该任务类型可以包括图像识别,图像分类,图像超分辨率重建等等。
在神经网络层230中的多层隐含层之后,也就是整个卷积神经网络200的最后层为输出层240,该输出层240具有类似分类交叉熵的损失函数,具体用于计算预测误差,一旦整个卷积神经网络200的前向传播(如图17由210至240方向的传播为前向传播)完成,反向传播(如图17由240至210方向的传播为反向传播)就会开始更新前面提到的各层 的权重值以及偏差,以减少卷积神经网络200的损失,及卷积神经网络200通过输出层输出的结果和理想结果之间的误差。
需要说明的是,如图17所示的卷积神经网络200仅作为一种卷积神经网络的示例,在具体的应用中,卷积神经网络还可以以其他网络模型的形式存在。
本申请中,可以采用图17所示的卷积神经网络200对待处理图像进行处理,得到待处理图像的分类结果。如图17所示,待处理图像经过输入层210、卷积层/池化层220以及神经网络层230的处理后输出待处理图像的分类结果。
图18为本申请实施例提供的一种芯片硬件结构,该芯片包括神经网络处理器50。该芯片可以被设置在如图16所示的执行设备110中,用以完成计算模块111的计算工作。该芯片也可以被设置在如图16所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则101。如图17所示的卷积神经网络中各层的算法均可在如图18所示的芯片中得以实现。
神经网络处理器NPU 50作为协处理器挂载到主CPU(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路503,控制器504控制运算电路503提取存储器(权重存储器或输入存储器)中的数据并进行运算。
在一些实现方式中,运算电路503内部包括多个处理单元(process engine,PE)。在一些实现方式中,运算电路503是二维脉动阵列。运算电路503还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现方式中,运算电路503是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路503从权重存储器502中取矩阵B相应的数据,并缓存在运算电路503中每一个PE上。运算电路503从输入存储器501中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)508中。
向量计算单元507可以对运算电路503的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。例如,向量计算单元507可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。
在一些实现方式中,向量计算单元能507将经处理的输出的向量存储到统一缓存器506。例如,向量计算单元507可以将非线性函数应用到运算电路503的输出,例如累加值的向量,用以生成激活值。在一些实现方式中,向量计算单元507生成归一化的值、合并值,或二者均有。在一些实现方式中,处理过的输出的向量能够用作到运算电路503的激活输入,例如用于在神经网络中的后续层中的使用。
统一存储器506用于存放输入数据以及输出数据。
权重数据直接通过存储单元访问控制器505(direct memory access controller,DMAC)将外部存储器中的输入数据搬运到输入存储器501和/或统一存储器506、将外部存储器中的权重数据存入权重存储器502,以及将统一存储器506中的数据存入外部存储器。
总线接口单元(bus interface unit,BIU)510,用于通过总线实现主CPU、DMAC和取指存储器509之间进行交互。
与控制器504连接的取指存储器(instruction fetch buffer)509,用于存储控制器504使用的指令;
控制器504,用于调用指存储器509中缓存的指令,实现控制该运算加速器的工作过程。
一般地,统一存储器506,输入存储器501,权重存储器502以及取指存储器509均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random access memory,简称DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。
其中,图17所示的卷积神经网络中各层的运算可以由运算电路503或向量计算单元307执行。
上文中介绍的图16中的执行设备110能够执行本申请实施例的图像分类方法的各个步骤,图17所示的CNN模型和图18所示的芯片也可以用于执行本申请实施例的图像分类方法的各个步骤。下面结合附图对本申请实施例的图像分类方法进行详细的介绍。
本申请实施例提供的图像分类方法可以在服务器上被执行,也可以在云端被执行,还可以在终端设备上被执行。以终端设备为例,如图19所示,本发明实施例的技术方案可以应用于终端设备,本申请实施例中的图像分类方法可以对输入图像进行图像分类,得到该输入图像的分类结果。该终端设备可以为移动的或固定的,例如该终端设备可以是具有图像处理功能的移动电话、平板个人电脑(tablet personal computer,TPC)、媒体播放器、智能电视、笔记本电脑(laptop computer,LC)、个人数字助理(personal digital assistant,PDA)、个人计算机(personal computer,PC)、照相机、摄像机、智能手表、可穿戴式设备(wearable device,WD)或者自动驾驶的车辆等,本发明实施例对此不作限定。
图像(或图片)的分类是各类图像处理应用的基础,计算机视觉常常会涉及到如何对获取到的图像进行分类的问题。但是,高精度的卷积神经网络的参数量和计算量都很大,而终端设备的内存和计算资源都非常有限,并不具备有较强的运算能力和缓存能力,导致具有高精度的卷积神经网络在终端设备上难以进行部署。
本申请实施例提出了一种图像分类方法,通过少于现有卷积神经网络中的标准卷积核个数的少量标准卷积核,就可以得到所需的输出特征图,该方法有助于降低图像分类处理的计算量和参数量。
图20示出了本申请实施例提供的图像分类方法500的示意性流程图,该方法可以由能够进行图像分类装置执行,例如,该方法可以由图19中的终端设备执行。
S510,获取待处理图像的输入特征图。
当图20所示的方法由图19中的终端设备执行时,该待处理图像可以是终端设备通过摄像头拍摄到的图像,或者,该待处理图像还可以是从终端设备内部获得的图像(例如,终端设备的相册中存储的图像,或者终端设备从云端获取的图像)。
或者,该待处理图像的输入特征图可以是卷积神经网络中的其他层处理后得到的特征图。应理解,这里所说的卷积神经网络中的其他层是指卷积神经网络中的一个层,例如,该其他层可以是卷积神经网络中的输入层、卷积层、池化层或全连接层中的一个。
S520,根据神经网络的M个卷积核对所述输入特征图进行卷积处理,得到M个通道的候选输出特征图,M为正整数。
其中,所述M个卷积核可以为现有卷积神经网络中的标准卷积核。
需要说明的是,在本申请实施例中,标准卷积核的通道数与输入特征图的通道数相同, 例如,若待处理图像的输入特征图的通道数为C,则现有卷积神经网络中的标准卷积核的通道数也为C,即,标准卷积核的通道数与输入特征图的通道数相同,其中,C为正整数。
S530,根据N个矩阵对所述候选输出特征图的M个通道进行矩阵变换,得到N个通道的输出特征图。
其中,所述N个矩阵中的每个矩阵的通道数小于M,N大于M,N为正整数。
上述S520和S530是本申请实施例中的特征扩增单元(feature in feature,FiF),该特征扩增单元可以用于替换现有卷积神经网络模型中的卷积层。
该特征扩增单元使用少量标准卷积核进行卷积处理,得到少量的候选特征图,并对这些少量的候选特征图进行矩阵变换以得到所需的输出特征图,可以减少输出特征图之间的冗余性,有助于降低图像分类处理的计算量和参数量。下面结合图21和图22对上述S520和S530中的特征扩增单元进行详细描述。
图21所示的是现有卷积神经网络中的一个卷积层的卷积处理。
从图21中可以看出,该卷积层的输入特征图包括C个通道,该卷积层的输出特征图包括N个通道。在现有卷积神经网络中,若要对C个通道的输入特征图进行卷积处理,得到N个通道的输出特征图,则该卷积层中需要N个标准卷积核,该N个标准卷积核中的每个卷积核包括C个通道。
需要说明的是,上述C个通道的输入特征图可以是指一个输入特征图,该输入特征图的通道数为C;或者,上述C个通道的输入特征图也可以是指C个输入特征图,其中,每个输入特征图都是二维的(即通道数为1)。为便于理解,本申请中统一描述为C个通道的输入特征图。本申请实施例中的其他特征图的描述都可以类似地理解,这里不再赘述。
例如,在上述S520中,得到M个通道的候选输出特征图,该M个通道的候选输出特征图既可以认为是一个包括M个通道的候选输出特征图,也可以是M个通道数为1的候选输出特征图。
图22所示的是本申请实施例中的特征扩增单元的特征扩增处理。该特征扩增单元可以用于替换现有卷积神经网络中的卷积层(例如图21所示的卷积层)。
在图22所示的特征扩增单元中,在输入特征图包括C个通道的情况下,若期望得到N个通道的输出特征图,可以先通过M个标准卷积核进行卷积处理,得到M个通道的候选特征图(如上述S520),该M个标准卷积核中的每个卷积核包括C个通道;再利用N个矩阵对候选输出特征图的M个通道进行矩阵变换,得到N个通道的输出特征图(如上述S530);其中,该N个矩阵中的每个矩阵的通道数可以小于M,N可以大于M,N为正整数。
在现有卷积神经网络中,同一个卷积层中可以有大量的标准卷积核,其中的很多卷积核的提取模式都是相似的,也就是说提取的特征都是类似的,导致得到输出特征图的冗余性很高。而在本申请中,该特征扩增单元基于少量标准卷积核进行卷积处理,并对得到的少量候选特征图的各个通道进行矩阵变量,可以有效减少各输出特征图之间的冗余性。
同时,该特征扩增单元中的标准卷积核的数量少于现有卷积神经网络,而且矩阵变换中使用的矩阵的通道数也小于标准卷积核,因此,有助于减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量。
在本申请中,上述矩阵变换中的所述N个矩阵可以是N个通道数为1的矩阵;或者上述矩阵变换中的所述N个矩阵也可以是N个通道数大于1的矩阵,例如,所述N个矩 阵的通道数为2。
同时,S530中是根据N个矩阵对特征图(所述M个通道的候选输出特征图)进行矩阵变换,而通常卷积核也可以认为是矩阵,因此,所述N个矩阵也可以认为是N个卷积核。在图20中的后续描述中,所述N个矩阵可以理解为所述N个卷积核,所述N个卷积核也可以指对所述M个通道的候选输出特征图进行矩阵变换的所述N个矩阵。
需要说明的是,这里所说的N个卷积核(上述N个卷积核)与S520中的卷积核不同,S520中的卷积核为现有卷积神经网络中的标准卷积核,标准卷积核的通道数与进行卷积的输入特征图的通道数相同,而本申请中的上述N个卷积核中的每个卷积核的通道数可以小于进行卷积的输入特征图的通道数M(即所述M个通道的候选输出特征图)。例如,所述N个卷积核的通道数可以为1。
进一步地,由于矩阵变换中的所述N个矩阵(即上述N个卷积核)的通道数可以小于所述候选输出特征图的通道数M,因此,可以减少特征扩增单元的计算量和参数量,在利用该特征扩增单元替换现有卷积神经网络中的卷积层(例如图21所示的卷积层)的情况下,有助于减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量。
在本申请中,根据矩阵变换中的所述N个矩阵的通道数不同,可以分为以下两种情况。
情况一:
可选地,上述矩阵变换中的所述N个矩阵的通道数可以为1。
可选地,所述N个矩阵可以分为M组卷积核,所述M组卷积核可以分别与所述候选输出特征图的M个通道对应。
可选地,所述M组卷积核可以与所述候选输出特征图的M个通道一一对应。
例如,所述M组卷积核中的第一组可以与所述候选输出特征图的M个通道中的第一个通道对应,所述M组卷积核中的第二组可以与所述候选输出特征图的M个通道中的第二个通道对应,……,所述M组卷积核中的第M组可以与所述候选输出特征图的M个通道中的第M个通道对应。
在本申请中,所述根据N个矩阵对所述M个候选输出特征图进行矩阵变换,得到N个通道的输出特征图,可以包括:根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行卷积,得到所述N个通道的输出特征图。
具体地,可以使用所述M组卷积核中的第一组,对所述候选输出特征图的M个通道中的第一个通道进行卷积,……,可以使用所述M组卷积核中的第M组,对所述候选输出特征图的M个通道中的第M个通道进行卷积。
例如,若所述M组卷积核中的第一组包括S个卷积核(该卷积核的通道数为1),如图22所示的Φ1,1至Φ1,s,则可以使用这S个卷积核,对所述候选输出特征图的M个通道中的第一个通道进行卷积,得到S个输出特征图(或者也可以认为是一个通道数为S的输出特征图)。
所述M组卷积核中的其他组卷积核类似,也可以S个卷积核,这里不再赘述。
可选地,在上述矩阵变换中的所述N个矩阵的通道数为1的情况下,该特征扩增单元的浮点计算次数(floating point operations,FLOPs)rS可以近似用下述公式(1)表示:
其中,S为所述M组卷积核中的每个组包括的卷积个数,C为所述特征扩增单元的输入特征图的通道数。
可选地,在S远小于C的情况,上述公式(1)可以近似用下述公式(2)表示:
类似地,在上述矩阵变换中的所述N个矩阵的通道数为1的情况下,该特征扩增单元的参数量的压缩比rC可以近似用下述公式(3)表示:
其中,S为所述M组卷积核中的每个组包括的卷积个数,C为所述特征扩增单元的输入特征图的通道数。
可选地,在S远小于C的情况,上述公式(3)可以近似用下述公式(4)表示:
在本申请中,所述根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行卷积,得到所述N个通道的输出特征图,可以包括:根据所述M组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行深度卷积(depthwise convolution),得到所述N个通道的输出特征图。
具体地,所述深度卷积可以参考现有技术,这里不再赘述。
在本申请中,所述M组卷积核中的每一组的卷积核与所述M组卷积核中的其他组的卷积核相同。
也就是说,所述候选输出特征图的M个通道可以复用相同的卷积核进行卷积。
例如,所述M组卷积核中的第一组包括S个卷积核,比如图7所示的Φ1,1至Φ1,s,可以依次使用这S个卷积核,对所述候选输出特征图的M个通道中的第一个通道进行卷积;所述M组卷积核中的第二组包括的S个卷积核也可以是图7所示的Φ1,1至Φ1,s,可以依次使用这S个卷积核,对所述候选输出特征图的M个通道中的第二个通道进行卷积。
类似地,所述M组卷积核中的其他组包括的S个卷积核也可以是图22所示的Φ1,1至Φ1,s,这里不再赘述。
由于矩阵变换中的所述N个矩阵(即上述N个卷积核)的通道数为1(小于所述候选输出特征图的通道数M),因此,可以减少特征扩增单元的计算量和参数量,降低图像分类处理的计算量和参数量。
情况二:
可选地,上述矩阵变换中的所述N个矩阵的通道数可以大于1。
以上述矩阵变换中的所述N个矩阵的通道数等于2为例,所述N个矩阵可以分为M/2组卷积核,所述M/2组卷积核可以分别与所述候选输出特征图的M个通道中的2个通道一一对应。
需要说明的是,本领域技术人员可以理解,在N个卷积核的通道数为2的情况下,若要根据N个卷积核对输入特征图(即所述M个通道的候选输出特征图)进行矩阵变换,则所述N个卷积核中的每个卷积核的通道数需要与输入特征图的通道数一致(或者说相同)。
此时,所述M个通道的候选输出特征图相当于划分为M/2个通道数为2的特征图,与所述N个卷积核进行卷积,相应地,所述N个卷积核也相当于划分为M/2组卷积核。应理解,这里所说的“划分”只是便于理解进行的解释性描述,在实际中可能并不存在划分的操作。
例如,所述M/2组卷积核中的第一组可以与所述候选输出特征图的M个通道中的第一个通道及第二个通道对应,所述M/2组卷积核中的第二组可以与所述候选输出特征图的M个通道中的第三个通道及第四个通道对应,……,所述M/2组卷积核中的第M/2组可以与所述候选输出特征图的M个通道中的第M-1个通道及第M个通道对应。
可选地,可以根据所述M/2组卷积核中的每一组卷积核,对所述候选输出特征图的M个通道中对应的通道进行卷积,得到所述N个通道的输出特征图。
例如,可以使用所述M/2组卷积核中的第一组,对所述候选输出特征图的M个通道中的第一个通道及第二个通道进行卷积,……,可以使用所述M/2组卷积核中的第M/2组,对所述候选输出特征图的M个通道中的第M-1个通道及第M个通道进行卷积。
可选地,所述M/2组卷积核中的每一组的卷积核与所述M/2组卷积核中的其他组的卷积核相同。也就是说,所述候选输出特征图的M个通道可以复用相同的卷积核进行卷积。
在本申请实施例中,矩阵变换中的所述N个矩阵的通道数大于2的情况与上述矩阵变换中的所述N个矩阵的通道数等于2的实施例类似,这里不再赘述。
由于矩阵变换中的所述N个矩阵(即上述N个卷积核)的通道数可以小于所述候选输出特征图的通道数M,因此,可以减少特征扩增单元的计算量和参数量,降低图像分类处理的计算量和参数量。
可选地,矩阵变换中的所述N个矩阵(即上述N个卷积核)的通道数可以等于所述候选输出特征图的通道数M。
在本申请中,所述根据所述输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果,可以包括:对所述候选输出特征图和所述输出特征图进行特征拼接,得到特征拼接特征图,所述特征拼接特征图的通道数为M+N;根据所述特征拼接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
上述特征拼接是指所述候选输出特征图和所述输出特征图在深度方向上组成新的特征图,即上述特征拼接特征图。
例如,所述候选输出特征图的通道数为M,所述输出特征图的通道数为N,所述候选输出特征图和所述输出特征图可以进行特征拼接,得到一个通道数为M+N的特征拼接特征图。
特征拼接可以通过恒等特征映射的方式,可以将更多的细节(或特征)引入输出特征图,同时,这种恒等映射并不会引入额外的参数或者计算量,因此可以在不增加参数量和计算量的情况下,提升图像分类的效果。
S540,根据所述输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
图23示出了本申请另一个实施例提供的图像分类方法800的示意性流程图,该方法可以由能够进行图像分类装置执行,例如,该方法可以由图19中的终端设备执行。
S810,获取待处理图像的输入特征图。
当图20所示的方法由图19中的终端设备执行时,该待处理图像可以是终端设备通过摄像头拍摄到的图像,或者,该待处理图像还可以是从终端设备内部获得的图像(例如,终端设备的相册中存储的图像,或者终端设备从云端获取的图像)。
或者,该待处理图像的输入特征图可以是卷积神经网络中的其他层处理后得到的特征图。应理解,这里所说的卷积神经网络中的其他层是指卷积神经网络中的一个层,例如,该其他层可以是卷积神经网络中的输入层、卷积层、池化层或全连接层中的一个。
S820,根据神经网络的M个第一卷积核对所述输入特征图进行卷积处理,得到M个通道的第一候选输出特征图,M为正整数。
其中,所述M个第一卷积核可以为现有卷积神经网络中的标准卷积核。
S830,根据K个第一矩阵对所述M个第一候选输出特征图进行矩阵变换,得到K个通道的第一输出特征图。
其中,所述K个第一矩阵中的每个矩阵的通道数小于M,K大于M,K为正整数。
可选地,上述S820和S830可以是图20方法500中的一个特征扩增单元(feature in feature,FiF)。
为便于理解,下述实施例中也可以将S820和S830称为第一特征扩增单元。
S840,根据神经网络的P个第二卷积核对所述第一输出特征图进行卷积处理,得到P个通道的第二候选输出特征图,P为正整数。
其中,所述P个第二卷积核可以为现有卷积神经网络中的标准卷积核。
可选地,所述根据神经网络的P个第二卷积核对所述第一输出特征图进行卷积处理,得到P个通道的第二候选输出特征图,可以包括:对所述第一输出特征图进行深度卷积,得到深度卷积特征图;根据所述P个第二卷积核对所述深度卷积特征图进行卷积处理,得到所述第二候选输出特征图。
可选地,所述对所述第一输出特征图进行深度卷积,得到深度卷积特征图,可以包括:对所述第一输出特征图进行步幅大于1的深度卷积,得到所述深度卷积特征图。
S850,根据N个第二矩阵对所述P个第二候选输出特征图进行矩阵变换,得到N个通道的第二输出特征图。
其中,所述N个第二矩阵中的每个矩阵的通道数小于P,N大于P,N为正整数。
可选地,上述S840和S850也可以是图20方法500中的一个特征扩增单元(feature in feature,FiF)。
为便于理解,下述实施例中也可以将S840和S850称为第二特征扩增单元。
S860,根据所述第二输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
可选地,所述根据所述第二输出特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果,可以包括:对所述输入特征图和所述第二输出特征图进行残差连接,得到残差连接特征图;根据所述残差连接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
在本申请中,上述S820至S850可以是本申请实施例中的纺锤模块(spindle block),该纺锤模块可以用于替换现有卷积神经网络模型中的一个模块(block),比如,现有卷积神经网络模型中的一个模块可以包括两个卷积层。
为便于理解,下述实施例中的纺锤模块都是指上述图23方法800(S820至S850)中 的所述纺锤模块。
也就是说,该纺锤模块可以包括上述第一特征扩增单元和上述第二特征扩增单元。
纺锤模块可以由至少两个特征扩增单元(比如图20中所示的特征扩增单元)构成,该特征扩增单元使用少量标准卷积核进行卷积处理,得到少量的候选特征图,并对这些少量的候选特征图进行矩阵变换以得到所需的输出特征图,可以减少输出特征图之间的冗余性,有助于降低图像分类处理的计算量和参数量。下面结合图24和图25对上述S820至S850中的纺锤模块进行详细描述。
在本申请中,根据纺锤模块的步长(stride)不同,可以分为以下两种情况。
情况一:
图24所示的是本申请实施例中的步长为1的纺锤模块。该纺锤可以由至少两个特征扩增单元(比如图20中所示的特征扩增单元)构成。
对于步长为1的纺锤模块,输入特征图的尺寸(宽和高)与输出特征图的尺寸相同。
例如,上述纺锤模块的输入特征图为所述待处理图像的输入特征图,上述纺锤模块的输出特征图为N个通道的第二输出特征图,若所述输入特征图的尺寸为A*B,则所述第二输出特征图的尺寸也为A*B。
可选地,在所述纺锤模块中,在所述第一特征扩增单元和所述第二特征扩增单元之间还可以进行深度卷积。可选地,所述深度卷积的步长可以为1。
可选地,在所述纺锤模块的步长为1的情况下,所述纺锤模块的输入特征图的尺寸(宽和高)与输出特征图的尺寸相同,因此,还可以对所述纺锤模块进行残差连接,即对所述输入特征图和所述第二输出特征图进行残差连接。
此时,可以对所述输入特征图和所述第二输出特征图进行残差连接,得到残差连接特征图;相应地,可以根据所述残差连接特征图对所述待处理图像进行分类,得到所述待处理图像的分类结果。
关于残差连接的详细描述可以参考现有技术,这里不再赘述。
通过残差连接可以将更多的细节(或特征)引入输出特征图,而残差连接并不会引入额外的参数或者计算量,因此,可以在不增加参数量和计算量的情况下,提升图像分类的效果。
情况二:
图25所示的是本申请实施例中的步长大于1的纺锤模块。该纺锤可以由至少两个特征扩增单元(比如图20中所示的特征扩增单元)构成。
对于步长大于1的纺锤模块,输出特征图的尺寸(宽和高)小于输入特征图的尺寸。
以纺锤模块的步长等于2为例进行说明,此时,输出特征图的尺寸(宽和高)为输入特征图的尺寸的一半。
例如,上述纺锤模块的输入特征图为所述待处理图像的输入特征图,上述纺锤模块的输出特征图为N个通道的第二输出特征图,若所述输入特征图的尺寸为A*B,则所述第二输出特征图的尺寸也为(A/2)*(B/2)。
可选地,在所述纺锤模块中,在所述第一特征扩增单元和所述第二特征扩增单元之间还可以进行深度卷积。可选地,所述深度卷积的步长可以大于1。
在本申请实施例中,所述纺锤模块的输出特征图的通道数可以为N(即N个通道的第二输出特征图),所述第一特征扩增单元的输出特征图的通道数可以为K(即K个通道的 第一输出特征图),可以使所述第一特征扩增单元的输出的通道数K大于N,相应地,再通过所述第二特征扩增单元将通道数K降为N。
也就是说,在所述纺锤模块中,可以通过所述第一特征扩增单元提高通道数,再通过所述第二特征扩增单元降低通道数,以满足所述纺锤模块输出的通道数。
例如,所述纺锤模块的输出特征图的通道数为100(即100个通道的第二输出特征图),所述第一特征扩增单元的输出特征图的通道数可以为1000(即1000个通道的第一输出特征图),此时,所述第一特征扩增单元输出的通道数1000大于所述纺锤模块输出的通道数100,相应地,可以再通过所述第二特征扩增单元将通道数1000降为100。
在本申请实施例中,通过所述第一特征扩增单元提高通道数,可以提取更多的特征,从而能够提升图像分类的效果。
进一步地,本申请实施例中的特征扩增单元可以通过少量标准卷积核及矩阵变换实现现有卷积神经网络中的卷积处理,可以有效减少各输出特征图之间的冗余性,减少神经网络模型的计算量和参数量,从而降低图像分类处理的计算量和参数量,因此,本申请实施例中的纺锤模块可以不增加参数量和计算量(或者减少参数量和计算量)的情况下,提升图像分类的效果。
图26是本申请实施例提供的一个神经网络的示意性框图。图26所示的神经网络可以用于实现图23所示的图像分类方法
图26中的神经网络可以包括一个或多个图23方法800中的纺锤模块,该纺锤模块可以用于替换现有卷积神经网络模型中的一个模块(block),比如,现有卷积神经网络模型中的一个模块可以包括两个卷积层。
该纺锤模块可以包括至少两个图20所示的特征扩增单元,例如,该纺锤模块可以如图23方法800中所述,包括两个特征扩增单元:第一特征扩增单元和第二特征扩增单元。其中,一个特征扩增单元可以用于替换现有卷积神经网络模型中的一个卷积层。
在图26所示的神经网络中,还可以包括卷积层、池化层或全连接层等,本申请对此并不限定。
根据图26所示的神经网络结构,本申请实施例提出一种高效的神经网络模型HWNet。HWNet如图26中神经网络所示,包括多个纺锤模块,其中,每个纺锤模块包括特征扩增模块,HWNet的网络结构可以参考现有神经网络的设计准则。例如,在现有神经网络的设计中,随着特征图尺寸的逐渐下降,特征图的通道数逐渐增加。HWNet的具体结构可以如下述表1所示。
表1本申请中的HWNet的网络结构

如表1所示,HWNet的第一层是带有16个标准卷积核的卷积层,然后是12个输入特征图的通道数逐渐增加的纺锤模块,这些纺锤模块组被分为5个阶段,每一阶段内的特征图大小相同。
下述表2是对HWNet和现有的几个神经网络模型,在ImageNet数据集上进行图像分类的测试实验数据。
表2本申请中的HWNet和现有的几个神经网络模型的测试数据
其中,MobileNet是谷歌公司(Google)提出的一种卷积神经网络模型,ShuffleNet是旷视科技公司提出的一种为移动终端设备而设计的卷积神经网络模型,IGCV3是交错低秩分组卷积。
从上表2可以看出,相比现有的几个神经网络模型,本申请实施例中提出的HWNet在参数更少、计算更快的情况下,模型的精度更高。
图27是本申请实施例的图像分类装置的硬件结构示意图。图27所示的图像分类装置4000包括存储器4001、处理器4002、通信接口4003以及总线4004。其中,存储器4001、处理器4002、通信接口4003通过总线4004实现彼此之间的通信连接。
存储器4001可以是只读存储器(read only memory,ROM),静态存储设备,动态存储设备或者随机存取存储器(random access memory,RAM)。存储器4001可以存储程序,当存储器4001中存储的程序被处理器4002执行时,处理器4002和通信接口4003用于执行本申请实施例的图像分类方法的各个步骤。
处理器4002可以采用通用的中央处理器(central processing unit,CPU),微处理器,应用专用集成电路(application specific integrated circuit,ASIC),图形处理器(graphics processing unit,GPU)或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例的图像分类装置中的单元所需执行的功能,或者执行本申请方法实施例的图像分类方法。
处理器4002还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请实施例的图像分类方法的各个步骤可以通过处理器4002中的硬件的集成逻辑电路或者软件形式的指令完成。
上述处理器4002还可以是通用处理器、数字信号处理器(digital signal processing,DSP)、ASIC、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。上述通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器4001,处理器4002读取存储器4001中的信息,结合其硬件完成本申请实施例的图像分类装置中包括的单元所需执行的功能,或者执行本申请方法实施例的图像分类方法。
通信接口4003使用例如但不限于收发器一类的收发装置,来实现装置4000与其他设备或通信网络之间的通信。例如,可以通过通信接口4003获取待处理图像。
总线4004可包括在装置4000各个部件(例如,存储器4001、处理器4002、通信接口4003)之间传送信息的通路。
图28是本申请实施例的神经网络训练装置5000的硬件结构示意图。与上述装置4000类似,图28所示的神经网络训练装置5000包括存储器5001、处理器5002、通信接口5003以及总线5004。其中,存储器5001、处理器5002、通信接口5003通过总线5004实现彼此之间的通信连接。
存储器5001可以存储程序,当存储器5001中存储的程序被处理器5002执行时,处理器5002用于执行训练本申请实施例的图像分类装置的训练方法的各个步骤。
处理器5002可以采用通用的CPU,微处理器,ASIC,GPU或者一个或多个集成电路, 用于执行相关程序,以实现训练本申请实施例的图像分类装置的训练方法。
处理器5002还可以是一种集成电路芯片,具有信号的处理能力。在实现训练过程中,本申请实施例的图像分类装置的训练方法的各个步骤可以通过处理器5002中的硬件的集成逻辑电路或者软件形式的指令完成。
应理解,通过图28所示的神经网络训练装置5000对图像分类装置进行训练,训练得到的图像分类装置就可以用于执行本申请实施例的图像分类方法了。具体地,通过装置5000对神经网络进行训练能够得到图20或图23所示的方法中的神经网络。
具体地,图28所示的装置可以通过通信接口5003从外界获取训练数据以及待训练的图像分类装置,然后由处理器根据训练数据对待训练的图像分类装置进行训练。
应注意,尽管上述装置4000和装置5000仅仅示出了存储器、处理器、通信接口,但是在具体实现过程中,本领域的技术人员应当理解,装置4000和装置5000还可以包括实现正常运行所必须的其他器件。同时,根据具体需要,本领域的技术人员应当理解,装置4000和装置5000还可包括实现其他附加功能的硬件器件。此外,本领域的技术人员应当理解,装置4000和装置5000也可仅仅包括实现本申请实施例所必须的器件,而不必包括图27和图28中所示的全部器件。
应理解,本申请实施例中的处理器可以为中央处理单元(central processing unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
还应理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的随机存取存储器(random access memory,RAM)可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令或计算机程序。在计算机上加载或执行所述计算机指令或计算机程序时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通 过有线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质。半导体介质可以是固态硬盘。
应理解,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,其中A,B可以是单数或者复数。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系,但也可能表示的是一种“和/或”的关系,具体可参考前后文进行理解。
本申请中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而 前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (23)

  1. 一种数据处理方法,其特征在于,所述方法包括:
    根据目标映射关系,确定目标词向量token对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址,所述存储地址对应的存储空间位于计算单元之外的存储空间;
    从所述存储地址对应的存储空间中获取所述一个或多个目标网络单元;所述一个或多个目标网络单元用于构建神经网络;
    根据所述目标词向量,通过所述计算单元执行所述神经网络对应的训练过程。
  2. 根据权利要求1所述的方法,其特征在于,不同的所述目标网络单元为不同的前向传播网络FFN。
  3. 根据权利要求1或2所述的方法,其特征在于,所述计算单元为图形处理器GPU、张量处理器TPU或者神经网络处理器NPU。
  4. 根据权利要求1至3任一所述的方法,其特征在于,所述存储地址对应的存储空间位于内存、网络存储器或者硬盘。
  5. 根据权利要求1至4任一所述的方法,其特征在于,所述目标映射关系包括第一目标映射关系,所述第一目标映射关系指示多个词向量以及每个词向量对应的一个或多个网络单元,所述第一目标映射关系具体为多级映射表。
  6. 根据权利要求1至5任一所述的方法,其特征在于,所述通过所述计算单元执行所述目标神经网络对应的训练过程用于得到更新后的目标神经网络,所述更新后的目标神经网络包括更新后的所述一个或多个目标网络单元,所述方法还包括:
    根据所述更新后的所述一个或多个目标网络单元,更新所述存储地址对应的存储空间中的数据。
  7. 根据权利要求1至6任一所述的方法,其特征在于,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述方法还包括:
    接收到用户针对于第二目标映射关系的修改信息,其中,所述第二目标映射关系包括多个词向量以及每个词向量对应的网络单元;
    根据所述修改信息,修改第二目标映射关系,以得到所述目标映射关系。
  8. 根据权利要求5至7任一所述的方法,其特征在于,所述修改信息用于指示如下的至少一种:
    对所述第二目标映射关系中至少一个词向量对应的网络单元的删除、替换或者增加;
    对所述第二目标映射关系中包括的映射关系的删除、替换或者增加,所述映射关系为词向量以及词向量对应的网络单元。
  9. 根据权利要求1至6任一所述的方法,其特征在于,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述方法还包括:
    在通过所述目标词向量对所述神经网络执行训练过程中,基于训练损失的下降程度低于阈值,对第二目标映射关系中所述目标词向量对应的网络单元进行增加,以得到所述目 标映射关系。
  10. 根据权利要求1至9任一所述的方法,其特征在于,所述所述目标映射关系包括多个词单元以及每个词单元对应的网络单元,所述方法还包括:
    根据收敛后所述神经网络,从所述目标映射关系中包括的多个词单元中确定部分词单元对应的网络单元,所述收敛后所述神经网络中所述部分词单元对应的网络单元用于构建目标神经网络;所述目标神经网络用于进行模型推理。
  11. 一种数据处理装置,其特征在于,所述装置包括:
    处理模块,用于根据目标映射关系,确定目标词向量token对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址,所述存储地址对应的存储空间位于计算单元之外的存储空间;
    从所述存储地址对应的存储空间中获取所述一个或多个目标网络单元;所述一个或多个目标网络单元用于构建神经网络;
    模型训练模块,用于根据所述目标词向量,通过所述计算单元执行所述神经网络对应的训练过程。
  12. 根据权利要求11所述的装置,其特征在于,所述目标网络单元为前向传播网络FFN。
  13. 根据权利要求11或12所述的装置,其特征在于,所述计算单元为图形处理器GPU、张量处理器TPU或者神经网络处理器NPU。
  14. 根据权利要求11至13任一所述的装置,其特征在于,所述存储地址对应的存储空间位于内存、网络存储器或者硬盘。
  15. 根据权利要求11至14任一所述的装置,其特征在于,所述目标映射关系包括第一目标映射关系,所述第一目标映射关系指示多个词向量以及每个词向量对应的一个或多个网络单元,所述第一目标映射关系具体为映射表。
  16. 根据权利要求11至15任一所述的装置,其特征在于,所述通过所述计算单元执行所述目标神经网络对应的训练过程用于得到更新后的目标神经网络,所述更新后的目标神经网络包括更新后的所述一个或多个目标网络单元,所述处理模块,还用于:
    根据所述更新后的所述一个或多个目标网络单元,更新所述存储地址对应的存储空间中的数据。
  17. 根据权利要求11至16任一所述的装置,其特征在于,在所述根据目标映射关系,确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述处理模块,还用于:
    接收到用户针对于第二目标映射关系的修改信息,其中,所述第二目标映射关系包括多个词向量以及每个词向量对应的网络单元;
    根据所述修改信息,修改第二目标映射关系,以得到所述目标映射关系。
  18. 根据权利要求15至17任一所述的装置,其特征在于,所述修改信息用于指示如下的至少一种:
    对所述第二目标映射关系中至少一个词向量对应的网络单元的删除、替换或者增加;
    对所述第二目标映射关系中包括的映射关系的删除、替换或者增加,所述映射关系为词向量以及词向量对应的网络单元。
  19. 根据权利要求11至16任一所述的装置,其特征在于,在所述根据目标映射关系, 确定目标词向量对应的一个或多个目标网络单元以及所述一个或多个目标网络单元的存储地址之前,所述处理模块,还用于:
    在通过所述目标词向量对所述神经网络执行训练过程中,基于训练损失的下降程度低于阈值,对第二目标映射关系中所述目标词向量对应的网络单元进行增加,以得到所述目标映射关系。
  20. 根据权利要求11至19任一所述的装置,其特征在于,所述所述目标映射关系包括多个词单元以及每个词单元对应的网络单元,所述处理模块,还用于:
    根据收敛后所述神经网络,从所述目标映射关系中包括的多个词单元中确定部分词单元对应的网络单元,所述收敛后所述神经网络中所述部分词单元对应的网络单元用于构建目标神经网络;所述目标神经网络用于进行模型推理。
  21. 一种计算设备,其特征在于,所述计算设备包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为获取所述代码,并执行如权利要求1至10任一所述的方法。
  22. 一种计算机存储介质,其特征在于,所述计算机存储介质存储有一个或多个指令,所述指令在由一个或多个计算机执行时使得所述一个或多个计算机实施权利要求1至10任一所述的方法。
  23. 一种计算机程序产品,包括代码,其特征在于,在所述代码被执行时用于实现如权利要求1至10任一所述的方法。
PCT/CN2023/123636 2022-09-30 2023-10-09 一种数据处理方法及相关装置 WO2024067884A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211214438.0 2022-09-30
CN202211214438.0A CN115879508A (zh) 2022-09-30 2022-09-30 一种数据处理方法及相关装置

Publications (1)

Publication Number Publication Date
WO2024067884A1 true WO2024067884A1 (zh) 2024-04-04

Family

ID=85770203

Family Applications (2)

Application Number Title Priority Date Filing Date
PCT/CN2023/120541 WO2024067373A1 (zh) 2022-09-30 2023-09-22 一种数据处理方法及相关装置
PCT/CN2023/123636 WO2024067884A1 (zh) 2022-09-30 2023-10-09 一种数据处理方法及相关装置

Family Applications Before (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/120541 WO2024067373A1 (zh) 2022-09-30 2023-09-22 一种数据处理方法及相关装置

Country Status (2)

Country Link
CN (1) CN115879508A (zh)
WO (2) WO2024067373A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115879508A (zh) * 2022-09-30 2023-03-31 华为技术有限公司 一种数据处理方法及相关装置

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150220833A1 (en) * 2014-01-31 2015-08-06 Google Inc. Generating vector representations of documents
CN107451075A (zh) * 2017-09-22 2017-12-08 算丰科技(北京)有限公司 数据处理芯片和系统、数据存储转发和读取处理方法
CN108776832A (zh) * 2018-06-05 2018-11-09 腾讯科技(深圳)有限公司 信息处理方法、装置、计算机设备和存储介质
CN109242092A (zh) * 2018-09-29 2019-01-18 深圳市商汤科技有限公司 网络获取及图像处理方法和装置、电子设备、存储介质
CN112686317A (zh) * 2020-12-30 2021-04-20 北京迈格威科技有限公司 神经网络训练方法、装置、电子设备及存储介质
CN114492754A (zh) * 2022-01-27 2022-05-13 上海商汤临港智能科技有限公司 神经网络生成、数据处理方法、装置、电子设备及介质
CN115879508A (zh) * 2022-09-30 2023-03-31 华为技术有限公司 一种数据处理方法及相关装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108062505B (zh) * 2016-11-09 2022-03-18 微软技术许可有限责任公司 用于基于神经网络的动作检测的方法和设备
CN111047563B (zh) * 2019-11-26 2023-09-01 深圳度影医疗科技有限公司 一种应用于医学超声图像的神经网络构建方法
CN113902111A (zh) * 2021-12-09 2022-01-07 绍兴埃瓦科技有限公司 多芯片互连系统及神经网络加速处理方法

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150220833A1 (en) * 2014-01-31 2015-08-06 Google Inc. Generating vector representations of documents
CN107451075A (zh) * 2017-09-22 2017-12-08 算丰科技(北京)有限公司 数据处理芯片和系统、数据存储转发和读取处理方法
CN108776832A (zh) * 2018-06-05 2018-11-09 腾讯科技(深圳)有限公司 信息处理方法、装置、计算机设备和存储介质
CN109242092A (zh) * 2018-09-29 2019-01-18 深圳市商汤科技有限公司 网络获取及图像处理方法和装置、电子设备、存储介质
CN112686317A (zh) * 2020-12-30 2021-04-20 北京迈格威科技有限公司 神经网络训练方法、装置、电子设备及存储介质
CN114492754A (zh) * 2022-01-27 2022-05-13 上海商汤临港智能科技有限公司 神经网络生成、数据处理方法、装置、电子设备及介质
CN115879508A (zh) * 2022-09-30 2023-03-31 华为技术有限公司 一种数据处理方法及相关装置

Also Published As

Publication number Publication date
WO2024067373A1 (zh) 2024-04-04
CN115879508A (zh) 2023-03-31

Similar Documents

Publication Publication Date Title
WO2021120719A1 (zh) 神经网络模型更新方法、图像处理方法及装置
WO2021043193A1 (zh) 神经网络结构的搜索方法、图像处理方法和装置
US20220092351A1 (en) Image classification method, neural network training method, and apparatus
WO2022083536A1 (zh) 一种神经网络构建方法以及装置
WO2021164772A1 (zh) 训练跨模态检索模型的方法、跨模态检索的方法和相关装置
WO2022001805A1 (zh) 一种神经网络蒸馏方法及装置
WO2022042713A1 (zh) 一种用于计算设备的深度学习训练方法和装置
WO2021057056A1 (zh) 神经网络架构搜索方法、图像处理方法、装置和存储介质
WO2021022521A1 (zh) 数据处理的方法、训练神经网络模型的方法及设备
US20230215159A1 (en) Neural network model training method, image processing method, and apparatus
WO2021008206A1 (zh) 神经网络结构的搜索方法、图像处理方法和装置
WO2021164750A1 (zh) 一种卷积层量化方法及其装置
WO2021218517A1 (zh) 获取神经网络模型的方法、图像处理方法及装置
WO2021013095A1 (zh) 图像分类方法、图像分类模型的训练方法及其装置
WO2023221928A1 (zh) 一种推荐方法、训练方法以及装置
WO2021018245A1 (zh) 图像分类方法及装置
CN110222718B (zh) 图像处理的方法及装置
WO2024041479A1 (zh) 一种数据处理方法及其装置
WO2022007867A1 (zh) 神经网络的构建方法和装置
WO2022100165A1 (zh) 神经网络模型的训练方法、图像处理方法及装置
WO2021129668A1 (zh) 训练神经网络的方法和装置
WO2022170569A1 (zh) 数据处理方法和装置
WO2024067884A1 (zh) 一种数据处理方法及相关装置
US20220327835A1 (en) Video processing method and apparatus
WO2023185925A1 (zh) 一种数据处理方法及相关装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23871108

Country of ref document: EP

Kind code of ref document: A1