Patent Description:
With people's increasing attention to social public security and development of video capturing technologies and large-scale data storage technologies, a large quantity of surveillance cameras are used in densely-populated areas where a public security problem is prone to occur. An increasing quantity of surveillance videos are difficult to be manually processed. Therefore, a requirement for re-recognizing a pedestrian and the like in a surveillance video by using a computer emerges. Re-recognition is recognizing, in a surveillance video, a specific pedestrian that has appeared in a surveillance network. For example, in the surveillance network, the pedestrian appears under different cameras. A pedestrian re-identification task is to identify the pedestrian in the surveillance network, and re-identify, in a scenario of another camera, the target pedestrian that has appeared in the surveillance network. That is, the task is about how to re-identify a pedestrian when some candidate targets are given.

Thanks to development of deep learning, performance of image retrieval and recognition tasks has been greatly improved. However, an existing deep learning solution depends on data. In a same scenario, a large amount of training data can be used to obtain a deep model with excellent performance in a current scenario. However, during actual deployment of the deep model, scenario and training data distribution may be inconsistent. Consequently, performance of the deep model greatly deteriorates in a deployment scenario. To resolve a problem that performance deteriorates during deployment in a target scenario, a pair of unlabeled samples in the target scenario may be used for training, to improve performance in the target scenario.

In the conventional technology, in a process in which the pair of unlabeled samples in the target scenario is used for training, each sample is considered as an independent clustering category at the beginning, and a specific quantity of clustering categories are reduced in each iteration according to a minimum distance principle. As iteration proceeds, a quantity of clustering categories decreases, and performance of the model is gradually improved based on the training. Finally, models corresponding to different obtained quantities of clustering categories are verified, to determine a model with optimal performance. In the foregoing verification process, the models corresponding to the different obtained quantities of clustering categories need to be verified based on labeled samples. However, in some scenarios, the labeled samples are often difficult to obtain.

<CIT> discloses a kind of facial image recognition method, device, electronic equipment and storage medium, wherein the described method includes: obtaining multiple facial images; Feature extraction is carried out to the multiple facial image, obtains the corresponding multiple feature vectors of the multiple facial image; Multiple target objects to be identified are obtained according to the multiple feature vector; The multiple target object to be identified is assessed, the classification of the multiple facial image is obtained.

This application provides a model update method, and the method includes:.

In an optional design of the first aspect, the silhouette coefficient is calculated based on a degree of inter-category separation and a degree of intra-category cohesion. The degree of inter-category separation indicates a distance between different clustering categories. The degree of intra-category cohesion indicates a distance between different training images corresponding to a same clustering category.

In an optional design of the first aspect, a silhouette coefficient corresponding to the first target clustering result is greater than a silhouette coefficient corresponding to a clustering result other than the first target clustering result in the plurality of first clustering results.

In an optional design of the first aspect, the performing a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features includes:
performing the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features, and updating the parameter of the neural network model according to a second loss function after each time of first clustering processing.

In an optional design of the first aspect, the updating the parameter of the neural network model according to a second loss function after each time of first clustering processing includes:
updating the parameter of the neural network model according to the second loss function after each time of first clustering processing, to reduce, in a first clustering result obtained after a next time of first clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the first clustering result.

In an optional design of the first aspect, the plurality of times of first clustering processing include an ith time of clustering processing and a jth time of clustering processing; the jth time of clustering processing is after the ith time of clustering processing; and the performing a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features includes:.

In an optional design of the first aspect, the performing a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features includes:.

In an optional design of the first aspect, the second loss function includes a triplet loss function.

In an optional design of the first aspect, the updating a parameter of the neural network model according to a first loss function includes:
updating the parameter of the neural network model according to the triplet loss function and the second loss function, to reduce, in a second clustering result obtained after a next time of second clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the second clustering result, and increase a distance between different clustering categories in the second clustering result obtained after the next time of clustering processing.

According to a second aspect, this application provides a model update apparatus, where the apparatus includes:.

In an optional design of the second aspect, the silhouette coefficient is calculated based on a degree of inter-category separation and a degree of intra-category cohesion. The degree of inter-category separation indicates a distance between different clustering categories. The degree of intra-category cohesion indicates a distance between different training images corresponding to a same clustering category.

In an optional design of the second aspect, a silhouette coefficient corresponding to the first target clustering result is greater than a silhouette coefficient corresponding to a clustering result other than the first target clustering result in the plurality of first clustering results.

In an optional design of the second aspect, the first clustering module is specifically configured to:
perform the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features, and update the parameter of the neural network model according to a second loss function after each time of first clustering processing.

In an optional design of the second aspect, the first clustering module is specifically configured to:
update the parameter of the neural network model according to the second loss function after each time of first clustering processing, to reduce, in a first clustering result obtained after a next time of first clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the first clustering result.

In an optional design of the second aspect, the plurality of times of first clustering processing include an ith time of clustering processing and a jth time of clustering processing; the jth time of clustering processing is after the ith time of clustering processing; and the first clustering module is specifically configured to:.

In an optional design of the second aspect, the first clustering module is specifically configured to:.

In an optional design of the second aspect, the second loss function includes a triplet loss function.

In an optional design of the second aspect, the second clustering module is specifically configured to:
update the parameter of the neural network model according to the triplet loss function and the second loss function, to reduce, in a second clustering result obtained after a next time of second clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the second clustering result, and increase a distance between different clustering categories in the second clustering result obtained after the next time of clustering processing.

According to a third aspect, an embodiment of this application provides a training device. The training device may include a memory, a processor, and a bus system. The memory is configured to store a program, and the processor is configured to execute the program in the memory, including the following steps:.

In the third aspect of this application, the processor may be further configured to perform the steps performed by an execution device in the possible implementations of the first aspect. For details, refer to the first aspect.

According to a fourth aspect, an embodiment of this application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program; and when the computer program runs on a computer, the computer is enabled to perform the model update method according to the optional designs of the first aspect.

According to a fifth aspect, an embodiment of this application provides a computer program. When the computer program runs on a computer, the computer performs the model update method according to the optional designs of the first aspect.

According to a sixth aspect, this application provides a chip system. The chip system includes a processor, configured to support an execution device or a training device to implement functions in the foregoing aspects, for example, sending or processing data and/or information in the foregoing method. In a possible design, the chip system further includes a memory. The memory is configured to store program instructions and data that are necessary for the execution device or the training device. The chip system may include a chip, or may include a chip and another discrete device.

An embodiment of this application provides the model update method. The method includes: obtaining the neural network model and the plurality of training images; performing feature extraction on the plurality of training images by using the neural network model to obtain the plurality of target features; performing the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features to obtain the plurality of first clustering results, where each of the plurality of first clustering results corresponds to one silhouette coefficient, and the silhouette coefficient indicates clustering quality; determining the first target clustering result from the plurality of first clustering results based on the plurality of silhouette coefficients corresponding to the plurality of first clustering results, where the first target clustering result includes the M clustering categories; and performing the second clustering processing on the plurality of training images based on the plurality of target features to obtain the second clustering result, and updating the parameter of the neural network model according to the first loss function, where the quantity of clustering categories included in the second clustering result is M. In the foregoing manner, an optimal quantity of clusters categories does not need to be determined by verifying, based on labeled samples, models corresponding to different obtained quantities of clustering categories, and the optimal quantity of clustering categories may be directly selected based on the first clustering result.

The following describes embodiments of the present disclosure with reference to the accompanying drawings in embodiments of the present disclosure. Terms used in an implementation part of the present disclosure are intended only to explain specific embodiments of the present disclosure, and not intended to limit the present disclosure.

The following describes embodiments of this application with reference to the accompanying drawings. A person of ordinary skill in the art may learn that, with technology development and emergence of a new scenario, the technical solutions provided in embodiments of this application are also applicable to a similar technical problem.

In the specification, claims, and accompanying drawings of this application, the terms "first", "second", and so on are intended to distinguish between similar objects but do not necessarily indicate a specific order or sequence. It should be understood that the terms used in such a way are interchangeable in proper circumstances, which is merely a discrimination manner that is used when objects having a same attribute are described in embodiments of this application. In addition, the terms "include", "have", and any other variant thereof are intended to cover a non-exclusive inclusion, so that a process, method, system, product, or device that includes a list of units is not necessarily limited to those units, but may include other units that are not expressly listed or are inherent to the process, method, product, or device.

An overall working procedure of an artificial intelligence system is first described. <FIG> is a schematic diagram of a structure of an artificial intelligence main framework. The following describes the artificial intelligence main framework from two dimensions: an "intelligent information chain" (a horizontal axis) and an "IT value chain" (a vertical axis). The "intelligent information chain" reflects a general process from data obtaining to data processing. For example, the process may be a general process of intelligent information perception, intelligent information representation and formation, intelligent inference, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects a value brought by artificial intelligence to the information technology industry from an underlying infrastructure and information (providing and processing technology implementation) of human intelligence to an industrial ecological process of a system.

The infrastructure provides computing capability support for the artificial intelligence system, implements communication with the external world, and implements support by using a base platform. A sensor is used to communicate with the outside. A computing capability is provided by an intelligent chip (a hardware acceleration chip such as a CPU, an NPU, a GPU, an ASIC, or an FPGA). The basic platform includes related platform assurance and support such as a distributed computing framework and a network, and may include cloud storage and computing, an interconnection and interworking network, and the like. For example, the sensor communicates with the outside to obtain data, and the data is provided to an intelligent chip in a distributed computing system for computation, where the distributed computing system is provided by the base platform.

Data at an upper layer of the infrastructure is used to indicate a data source in the field of artificial intelligence. The data relates to a graph, an image, a voice, and text, further relates to Internet of things data of a conventional device, and includes service data of an existing system and perception data such as force, displacement, a liquid level, a temperature, and humidity.

Data processing usually includes manners such as data training, machine learning, deep learning, search, inference, and decision-making.

Machine learning and deep learning may mean performing symbolic and formalized intelligent information modeling, extraction, preprocessing, training, and the like on data.

Inference is a process in which a human intelligent inference manner is simulated in a computer or an intelligent system, and machine thinking and problem resolving are performed by using formal information according to an inference control policy. A typical function of inference is search and matching.

Decision-making is a process in which a decision is made after intelligent information is inferred, and usually provides functions such as classification, ranking, and prediction.

After data processing mentioned above is performed on data, some general capabilities may be further formed based on a data processing result, for example, an algorithm or a general system, to perform translation, text analysis, computer vision processing, speech recognition, image recognition, and the like.

Intelligent products and industry applications refer to products and applications of the artificial intelligence system in various fields, and are encapsulation for an overall solution of artificial intelligence, to productize intelligent information decision-making and implement applications. Application fields thereof mainly include an intelligent terminal, intelligent transportation, intelligent healthcare, autonomous driving, a safe city, and the like.

This application may be applied to a field such as the safe city in the artificial intelligence field. The following describes an application scenario in this application.

A video surveillance product is becoming increasingly intelligent as construction of the safe city becomes increasingly urgent. The intelligent video analysis technology uses a computer to automatically analyze video content and mine valuable information from massive videos. In the past, it took people dozens of hours to watch surveillance videos. Thanks to an intelligent video analysis system, a result can be returned within several seconds. This greatly improves work efficiency.

In the intelligent video analysis system, a pedestrian re-identification technology associates people with a same appearance under different cameras, to infer a track of the pedestrian. The track is a spatio-temporal route that specifies an order of times and places. Input of the intelligent video analysis system is a query image that includes the pedestrian, or another specified query condition. The system searches massive image libraries or video libraries for all video clips that include the pedestrian or meet the query condition, and then infers the track of the pedestrian based on time and location information corresponding to a search result.

<FIG> is a schematic diagram of an application architecture according to an embodiment of this application. As shown in <FIG>, in a large data center, a large amount of labeled pedestrian re-identification (Re-identification, Re-ID) data may be used for training on a large server, to obtain a depth model M. The depth model M may extract image features of images, and may determine an image similarity based on the extracted image features. When the depth model M is deployed on a terminal side and is specifically used in a specific scenario, a large amount of unlabeled pedestrian data may be obtained by using a camera network, and adaptive training may be performed on the depth model M on the server by using the unlabeled data, to obtain a depth model applicable to a deployment scenario. In addition, for a same scenario, when data changes, for example, a season changes, adaptive training may be performed on the model by using the foregoing method to update the model, to obtain a depth model applicable to the deployment scenario.

Because embodiments of this application relate to massive application of a neural network, for ease of understanding, the following describes terms and concepts related to the neural network that may be used in embodiments of this application.

The neural network may include a neuron. The neuron may be an operation unit that uses xs and an intercept of <NUM> as input. Output of the operation unit may be as follows: <MAT> where
s=<NUM>, <NUM>,. , n, n is a natural number greater than <NUM>, Ws is a weight of Xs, and b is an offset of the neuron. f indicates an activation function (activation function) of the neuron, where the activation function is used for introducing a non-linear characteristic into the neural network, to convert an input signal in the neuron into an output signal. The output signal of the activation function may be used as input to a next convolutional layer, and the activation function may be a sigmoid function. The neural network is a network constituted by connecting a plurality of single neurons together. To be specific, output of a neuron may be input to another neuron. Input of each neuron may be connected to a local receptive field of a previous layer to extract a feature of the local receptive field. The local receptive field may be a region including several neurons.

The deep neural network (deep neural network, DNN) is also referred to as a multi-layer neural network, and may be understood as a neural network having a plurality of hidden layers. The DNN is divided based on positions of different layers. Neural networks inside the DNN may be classified into three types: an input layer, a hidden layer, and an output layer. Generally, the first layer is the input layer, the last layer is the output layer, and the middle layer is the hidden layer. Layers are fully connected. To be specific, any neuron at an ith layer is necessarily connected to any neuron at an (i+<NUM>)th layer.

Although the DNN seems complex, the DNN is actually not complex in terms of work at each layer, and is simply represented as the following linear relationship expression: <MAT>, where <MAT> is an input vector, <MAT> is an output vector, <MAT> is an offset vector, W is a weight matrix (also referred to as a coefficient), and α() is an activation function. At each layer, the output vector <MAT> is obtained by performing such a simple operation on the input vector <MAT>. Because there are a large quantity of DNN layers, there are also a large quantity of coefficients W and offset vectors <MAT>. Definitions of these parameters in the DNN are as follows: The coefficient W is used as an example. It is assumed that in a DNN having three layers, a linear coefficient from a fourth neuron at a second layer to a second neuron at a third layer is defined as <MAT>. The superscript <NUM> indicates a layer at which the coefficient W is located, and the subscript corresponds to an output third-layer index <NUM> and an input second-layer index <NUM>.

In conclusion, a coefficient from a kth neuron at a (L-<NUM>)th layer to a jth neuron at a Lth layer is defined as <MAT>.

It should be noted that there is no parameter W at the input layer. In the deep neural network, more hidden layers make the network more capable of describing a complex case in the real world. Theoretically, a model with more parameters has higher complexity and a larger "capacity". It means that the model can complete a more complex learning task. Training the deep neural network is a process of learning a weight matrix, and a final objective of the training is to obtain a weight matrix of all layers of a trained deep neural network (a weight matrix formed by vectors W at a plurality of layers).

The convolutional neural network (convolutional neuron network, CNN) is a deep neural network with a convolutional structure. The convolutional neural network includes a feature extractor including a convolution layer and a sub-sampling layer, and the feature extractor may be considered as a filter. The convolutional layer is a neuron layer that is in the convolutional neural network and at which convolution processing is performed on an input signal. At the convolutional layer of the convolutional neural network, one neuron may be connected to only a part of neurons at a neighboring layer. A convolutional layer usually includes several feature planes, and each feature plane may include some neurons arranged in a rectangle. Neurons of a same feature plane share a weight, and the shared weight herein is a convolution kernel. Sharing a weight may be understood as that a manner of extracting image information is unrelated to a location. The convolution kernel may be initialized in a form of a matrix of a random size. In a training process of the convolutional neural network, an appropriate weight may be obtained for the convolution kernel through learning. In addition, sharing the weight has advantages that connections between layers of the convolutional neural network are reduced, and a risk of overfitting is reduced.

In a process of training the deep neural network, because it is expected that output of the deep neural network is as much as possible close to a predicted value that is actually expected, a predicted value of a current network and a target value that is actually expected may be compared, and then a weight vector of each layer of the neural network is updated based on a difference between the predicted value and the target value (certainly, there is usually an initialization process before the first update, to be specific, parameters are preconfigured for all layers of the deep neural network). For example, if the predicted value of the network is large, the weight vector is adjusted to decrease the predicted value, and adjustment is continuously performed until the deep neural network can predict the target value that is actually expected or a value that is very close to the target value that is actually expected. Therefore, "how to compare a difference between the predicted value and the target value" needs to be predefined. This is a loss function (loss function) or an objective function (objective function). The loss function and the objective function are important equations that measure the difference between the predicted value and the target value. The loss function is used as an example. A higher output value (loss) of the loss function indicates a larger difference. Therefore, training of the deep neural network is a process of minimizing the loss as much as possible.

In a training process, a neural network may correct values of parameters in an initial neural network model by using an error back propagation (back propagation, BP) algorithm, so that a reconstruction error loss of the neural network model becomes increasingly smaller. Specifically, an input signal is forward transferred until an error loss occurs during output, and the parameters in the initial neural network model are updated based on back propagation error loss information, so that the error loss is reduced. The back propagation algorithm is a back propagation motion mainly dependent on the error loss, and is used for obtaining parameters of an optimal neural network model, for example, a weight matrix.

<FIG> is a schematic diagram of an embodiment of a model update method according to an embodiment of this application. As shown in <FIG>, the model update method provided in this embodiment of this application includes the following steps.

<NUM>: Obtain a neural network model and a plurality of training images.

In this embodiment of this application, a server may obtain the neural network model and the plurality of training images. The neural network model may be a deep model obtained by a cloud side device through training on a large server based on a large amount of labeled Re-ID data.

In this embodiment of this application, the server may obtain the plurality of training images, and the plurality of training images may be a large quantity of unlabeled pedestrian images obtained by using a camera network.

<NUM>: Perform feature extraction on the plurality of training images by using the neural network model to obtain a plurality of target features.

In this embodiment of this application, after obtaining the neural network model and the plurality of training images, the server may perform feature extraction on the plurality of training images by using the neural network model to obtain the plurality of target features. <FIG> is a schematic flowchart of a model update method according to an embodiment of this application. As shown in <FIG>, after obtaining the neural network model and the plurality of training images, the server may perform feature extraction on the plurality of training images by using the neural network model to obtain the plurality of target features.

<NUM>: Perform a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features to obtain a plurality of first clustering results, where each of the plurality of first clustering results corresponds to one silhouette coefficient, and the silhouette coefficient indicates clustering quality.

In this embodiment of this application, the silhouette coefficient is related to a degree of inter-category separation and a degree of intra-category cohesion. The degree of inter-category separation indicates a distance between different clustering categories. The degree of intra-category cohesion indicates a distance between different training images corresponding to a same clustering category.

In this embodiment of this application, the silhouette coefficient is positively correlated with the distance between different clustering categories, and the silhouette coefficient is negatively correlated with the distance between different training images corresponding to the same clustering category. The plurality of first clustering results include a second target clustering result and a first target clustering result. A silhouette coefficient corresponding to the first target clustering result is greater than a silhouette coefficient corresponding to the second target clustering result.

In this embodiment of this application, a progressive clustering manner may be used. Specifically, a clustering process may be divided into two phases. In a first clustering phase, the server may perform the plurality of times of clustering processing on the plurality of training images based on the plurality of target features to obtain the plurality of first clustering results.

Specifically, in the first clustering phase, the server may perform the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features, and update a parameter of the neural network model according to a second loss function after each time of first clustering processing.

A process of one time of clustering processing in the first clustering phase is used as an example. The server may perform one time of clustering processing on the plurality of training images based on the plurality of target features, and update the parameter of the neural network model according to the second loss function, to reduce, in a first clustering result obtained after a next time of first clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the first clustering result.

At the beginning of the first clustering phase, because clustering is incomplete, in an obtained first clustering result, a same target (for example, a pedestrian) may belong to different clustering categories. This impact may be reduced according to a soft multi-label learning policy. A loss function may be shown in the following formula: <MAT> where
L(xi) is a multi-label set matched by a training image i, <MAT> is a weight, vi is a target feature corresponding to the training image i, and C is a quantity of clustering categories in a clustering result. In each iteration, A categories that are most similar to the training image i may be selected, and A may be a preset quantity of clustering categories. In addition, to highlight a function of categories with a high similarity, a similarity is used as a weight αj. In this embodiment of this application, as a quantity of clustering categories decreases, soft multi-label learning may gradually degrade to single-label learning as data changes.

In this embodiment of this application, at the beginning of the first clustering phase, because clustering is incomplete, in the obtained first clustering result, a training image may belong to different clustering categories (a particular similarity exists between the training image and a plurality of clustering categories, so that the training image belongs to different clustering categories). However, in the plurality of clustering categories, the training image has a high similarity to only some of the clustering categories, and has a little similarity to other clustering categories. After the neural network model is updated according to the second loss function, similarities between the training image and the some of the clustering categories gradually increase, and similarities between the training image and the other clustering categories gradually decrease. Therefore, a variance of similarity distribution between the training image and some clustering categories included in the first clustering result gradually decreases, and the clustering categories that have the high similarity to the training image gradually aggregate on the some clustering categories included in the first clustering result. As the first clustering phase proceeds, soft multi-label learning can be gradually degraded to single-label learning as the data changes.

In this embodiment of this application, after each time of clustering processing, the neural network model may be updated according to the loss function, feature extraction is performed on the training images by using an updated neural network model to obtain the plurality of target features, and a next time of clustering processing is performed on the plurality of training images based on the obtained plurality of target features.

In this embodiment of this application, the quantity of clustering categories may gradually decrease with a quantity of iteration times based on a specific quantity, and clustering categories with a higher similarity are preferentially clustered into one category. In this embodiment of this application, a silhouette coefficient may be used as a clustering evaluation indicator, and an expression of the silhouette coefficient may be shown in the following formula: <MAT> where
bi is a degree of inter-category separation, and the degree of inter-category separation indicates a distance between different clustering categories.

For example, bi may be an average value of distances from the training image i to all samples in a neighboring clustering category (a closest clustering category), and is denoted as b. The neighboring clustering category may be understood as a clustering category closest to the training image i. It should be noted that, because which clustering category is a neighboring clustering category is unknown, other clustering categories need to be screened, and a clustering category whose distance to the training image is closest to the average value is selected as the neighboring clustering category.

ai is a degree of intra-category cohesion, and the degree of intra-category cohesion indicates a distance between different training images corresponding to a same clustering category.

For example, ai may be an average distance between the training image i and other samples of a same category with the training image i.

In this embodiment of this application, in a clustering process in the first phase, a quantity of clustering categories included in the first clustering result may be gradually reduced. After each clustering process ends, a silhouette coefficient corresponding to the first clustering result may be calculated. Finally, an optimal silhouette coefficient and a quantity M of clustering categories included in the corresponding first clustering result may be obtained.

In this embodiment of this application, in the clustering processing process in the first phase, the plurality of times of clustering processing may include an ith time of clustering processing and a jth time of clustering processing. The jth time of clustering processing is after the ith time of clustering processing. When performing the ith time of clustering processing and the jth time of clustering processing, the server may obtain a second similarity between all of the plurality of target features. The second similarity includes image feature similarities and spatio-temporal constraint weights that are between each of the plurality of target features, a spatio-temporal constraint weight when the jth clustering processing is performed is greater than a spatio-temporal constraint weight when the ith clustering processing is performed, and the spatio-temporal constraint weight indicates a capability of affecting the second similarity between the target features by a spatio-temporal constraint. The ith time of clustering processing and the jth time of clustering processing are performed on the plurality of training images based on the second similarity, where i and j are positive integers.

In this embodiment of this application, in first several times of the plurality of times of clustering processing, a spatio-temporal constraint may have great impact on a similarity between training images. For example, a plurality of training images are training images shot by a camera <NUM>, a plurality of training images are training images shot by a camera <NUM>, and shooting areas of the camera <NUM> and the camera <NUM> overlap greatly. Therefore, there is a spatio-temporal constraint between the training images shot by the camera <NUM> and the training images shot by the camera <NUM>. In the first several times of the plurality of times of clustering processing in the first clustering phase, because there is the spatio-temporal constraint between the training images shot by the camera <NUM> and the training images shot by the camera <NUM>, objects that may be clustered are, to a large extent, the training images shot by the camera <NUM> and the camera <NUM>.

In this embodiment of this application, the spatio-temporal constraint may be understood as a spatio-temporal transfer probability.

In this embodiment of this application, an adaptive adjustment process of the spatio-temporal constraint is added. A degree of the spatio-temporal constraint is adjusted based on a clustering status of each first clustering result, and the spatio-temporal constraint is reduced in the first several times of the plurality of times of clustering processing. For example, the plurality of times of clustering processing include the ith time of clustering processing and the jth time of clustering processing, and the jth time of clustering processing is after the ith time of clustering processing. When the ith time of clustering processing and the jth time of clustering processing are performed, the second similarity between all of the plurality of target features is obtained. The second similarity includes the image feature similarities and the spatio-temporal constraint weights between all of the plurality of target features, the spatio-temporal constraint weight when the jth clustering processing is performed is greater than the spatio-temporal constraint weight when the ith clustering processing is performed, and the spatio-temporal constraint weight indicates the capability of affecting the second similarity between the target features by a spatio-temporal constraint. The ith time of clustering processing and the jth time of clustering processing are performed on the plurality of training images based on the second similarity.

In this embodiment of this application, the server may obtain the second similarity between all of the plurality of target features. The second similarity includes the image feature similarities and the spatio-temporal constraint weights between all of the plurality of target features. The plurality of times of clustering processing are performed on the plurality of training images based on the second similarity, and the spatio-temporal constraint weights between all of the plurality of target features are updated based on the corresponding first clustering result after each time of clustering processing.

Specifically, the degree of the spatio-temporal constraint in the clustering process in the first phase may be updated according to the following formula: <MAT> where
sv(xi,xj) is a similarity based image features, PST(xi,xj) is a spatio-temporal transfer probability of an image, αi is a constraint degree obtained based on a clustering status, and s(xi,xj) is used as a final similarity for clustering.

<NUM>: Determine a first target clustering result from the plurality of first clustering results based on a plurality of silhouette coefficients corresponding to the plurality of first clustering results, where the first target clustering result includes M clustering categories.

In this embodiment of this application, in the clustering process in the first phase, the quantity of clustering categories included in the first clustering result may be gradually reduced. After each clustering process ends, the silhouette coefficients corresponding to the first clustering result may be calculated. Finally, the optimal silhouette coefficient and the quantity M of clustering categories included in the corresponding first clustering result may be obtained.

In this embodiment of this application, the silhouette coefficient is positively correlated with the distance between different clustering categories, and the silhouette coefficient is negatively correlated with the distance between different training images corresponding to the same clustering category. The plurality of first clustering results include the second target clustering result and the first target clustering result. The silhouette coefficient corresponding to the first target clustering result is greater than the silhouette coefficient corresponding to the second target clustering result. In other words, in this embodiment of this application, the largest silhouette coefficient may be selected as the optimal silhouette coefficient, and a quantity M of clustering categories included in a first clustering result corresponding to the largest silhouette coefficient is determined.

<NUM>: Perform second clustering processing on the plurality of training images based on the plurality of target features to obtain a second clustering result, and update the parameter of the neural network model according to a first loss function, where a quantity of clustering categories included in the second clustering result is M.

In this embodiment of this application, after the first target clustering result is determined from the plurality of first clustering results based on the plurality of silhouette coefficients corresponding to the plurality of first clustering results, where the first target clustering result includes the M clustering categories, second clustering processing may be performed on the plurality of training images based on the plurality of target features to obtain the second clustering result, and the parameter of the neural network model is updated according to the first loss function. The quantity of clustering categories included in the second clustering result is M.

In a clustering process in a second phase, feature extraction may be performed on the plurality of training images based on a neural network model that is obtained through update after a last time of clustering processing in the clustering process in the first phase, to obtain a plurality of target features. Clustering processing is performed on the plurality of training images based on the plurality of target features to obtain the second clustering result. The parameter of the neural network model is updated according to the first loss function, and the quantity of clustering categories included in the second clustering result is M. That is, in the clustering process in the second phase, a quantity of clustering categories included in a second clustering result obtained each time is the quantity M of clustering categories included in the first clustering result corresponding to the optimal silhouette coefficient determined in the clustering process in the first phase.

In the conventional technology, in a process in which a pair of unlabeled samples in a target scenario is used for training, each sample is considered as an independent clustering category at the beginning, and a specific quantity of clustering categories are reduced in each iteration according to a minimum distance principle. As iteration is performed, the quantity of clustering categories decreases, and model training performance is gradually improved. Finally, models corresponding to different quantities of clustering categories are verified, to determine a model with optimal performance. In the foregoing verification process, the models corresponding to different quantities of clustering categories obtained need to be verified based on labeled samples. However, in some scenarios, the labeled samples are difficult to obtain. Compared with the conventional technology, in this embodiment of this application, an optimal quantity of clusters categories does not need to be determined by verifying, based on the labeled samples, the obtained models corresponding to different quantities of clustering categories.

In this embodiment of this application, the first loss function includes a triplet loss function.

In this embodiment of this application, the server may update the parameter of the neural network model according to the triplet loss function and the second loss function, to reduce in a second clustering result obtained after a next time of clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the second clustering result, and a distance between different clustering categories in the second clustering result obtained after the next time of clustering processing.

In this embodiment of this application, the server may update the neural network model according to the triplet loss function, to further enhance a feature determining capability. The triplet loss function is as follows: <MAT> where
<MAT> indicates the target feature of the training image i, <MAT> indicates a target feature of a training image of a same type as the training image i, and <MAT> indicates a target feature of a training image of a different type from the training image i. A final objective of the triplet loss function is to make a distance between training images of different types greater than a distance between training images of a same type, to improve the feature determining capability of the neural network model. For specific descriptions of the second loss function, refer to the descriptions in the foregoing embodiment.

This embodiment of this application provides the model update method. The method includes: obtaining the neural network model and the plurality of training images; performing feature extraction on the plurality of training images by using the neural network model to obtain the plurality of target features; performing the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features to obtain the plurality of first clustering results, where each of the plurality of first clustering results corresponds to one silhouette coefficient, and the silhouette coefficient indicates clustering quality; determining the first target clustering result from the plurality of first clustering results based on a plurality of silhouette coefficient corresponding to the plurality of first clustering results, where the first target clustering result includes the M clustering categories; and performing second clustering processing on the plurality of training images based on the plurality of target features to obtain the second clustering result, and updating the parameter of the neural network model according to the first loss function, where the quantity of clustering categories included in the second clustering result is M. In the foregoing manner, the optimal quantity of clusters categories does not need to be determined by verifying, based on the labeled samples, the models corresponding to different obtained quantities of clustering categories, and the optimal quantity of clustering categories may be directly selected based on the first clustering result.

The following describes a system architecture provided in an embodiment of this application.

Refer to <FIG>. An embodiment of this application provides a system architecture <NUM>. As shown in the system architecture <NUM>, a data collection device <NUM> is configured to: collect training data, where the training data in this embodiment of this application includes a plurality of training images and a neural network model; and store the training data in a database <NUM>. A training device <NUM> trains and updates the neural network model based on the training data maintained in the database <NUM>. It should be noted that, during an actual application, the training data maintained in the database <NUM> is not necessarily all collected by the data collection device <NUM>, and may be received from another device. In addition, it should be noted that the training device <NUM> does not necessarily train the neural network model completely based on the training data maintained in the database <NUM>, and may obtain training data from a cloud or another place for model training. The foregoing description should not be construed as a limitation on this embodiment of this application.

A target model/rule obtained through training by the training device <NUM> may be applied to different systems or devices, for example, an execution device <NUM> shown in <FIG>. The execution device <NUM> may be a terminal, for example, a mobile phone terminal, a tablet computer, a laptop computer, augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR), or a vehicle-mounted terminal; or may be a server, a cloud, or the like. In <FIG>, an input/output (input/output, I/O) interface <NUM> is configured for the execution device <NUM>, and is configured to exchange data with an external device. A user may input data to the I/O interface <NUM> by using a client device <NUM>. The input data may include the plurality of training images and the neural network model in this embodiment of this application.

In a process in which the execution device <NUM> preprocesses the input data, or in a process in which a calculation module <NUM> of the execution device <NUM> performs related processing such as calculation (for example, implements a function of the neural network in this application), the execution device <NUM> may invoke data, code, and the like in a data storage system <NUM> for corresponding processing; or may store data, instructions, and the like obtained through corresponding processing into the data storage system <NUM>.

Finally, the I/O interface <NUM> returns a processing result to the client device <NUM>, to provide the processing result for the user.

It should be noted that the training device <NUM> may generate corresponding target models/rules for different targets or different tasks based on different training data. The corresponding target models/rules may be used to implement the targets or complete the tasks, to provide a required result for the user.

In a case shown in <FIG>, the user may manually provide the input data. Manually providing may be performed through an interface provided by the I/O interface <NUM>. In another case, the client device <NUM> may automatically send the input data to the I/O interface <NUM>. If it is required that the client device <NUM> needs to obtain authorization from the user to automatically send the input data, the user may set corresponding permission on the client device <NUM>. The user may check, on the client device <NUM>, the result output by the execution device <NUM>. Specifically, the result may be presented in a form of display, sound, an action, or the like. The client device <NUM> may also serve as a data collector to collect, as new sample data, the input data that is input to the I/O interface <NUM> and an output result that is output from the I/O interface <NUM> shown in the figure, and store the new sample data in the database <NUM>. Certainly, the client device <NUM> may alternatively not perform collection. Instead, the I/O interface <NUM> directly stores, as new sample data, the input data that is input to the I/O interface <NUM> and the output result that is output from the I/O interface <NUM> in the figure in the database <NUM>.

It should be noted that <FIG> is merely a schematic diagram of a system architecture according to an embodiment of this application. A location relationship between the devices, the components, the modules, and the like shown in the figure does not constitute any limitation. For example, in <FIG>, the data storage system <NUM> is an external memory relative to the execution device <NUM>, but in another case, the data storage system <NUM> may alternatively be disposed in the execution device <NUM>.

Based on the embodiments corresponding to <FIG>, to better implement the foregoing solutions in embodiments of this application, the following further provides a related device configured to implement the foregoing solutions. Specifically, <FIG> is a schematic diagram of a structure of a model update apparatus <NUM> according to an embodiment of this application. The model update apparatus <NUM> may be a terminal device or a server. The model update apparatus <NUM> includes:.

Optionally, the silhouette coefficient is calculated based on a degree of inter-category separation and a degree of intra-category cohesion. The degree of inter-category separation indicates a distance between different clustering categories. The degree of intra-category cohesion indicates a distance between different training images corresponding to a same clustering category.

Optionally, a silhouette coefficient corresponding to the first target clustering result is greater than a silhouette coefficient corresponding to a clustering result other than the first target clustering result in the plurality of first clustering results.

Optionally, the first clustering module is specifically configured to:
perform the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features, and update the parameter of the neural network model according to a second loss function after each time of first clustering processing.

Optionally, the first clustering module is specifically configured to:
update the parameter of the neural network model according to the second loss function after each time of first clustering processing, to reduce, in a first clustering result obtained after a next time of first clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the first clustering result.

Optionally, the plurality of times of first clustering processing include an ith time of clustering processing and a jth time of clustering processing, and the jth time of clustering processing is after the ith time of clustering processing. The first clustering module is specifically configured to:.

Optionally, the first clustering module is specifically configured to:.

Optionally, the second loss function includes a triplet loss function.

Optionally, the second clustering module is specifically configured to:
update the parameter of the neural network model according to the triplet loss function and the second loss function, to reduce, in a second clustering result obtained after a next time of second clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the second clustering result, and increase a distance between different clustering categories in the second clustering result obtained after the next time of clustering processing.

This embodiment of this application provides the model update apparatus. The obtaining module <NUM> obtains the neural network model and the plurality of training images. The feature extraction module <NUM> performs feature extraction on the plurality of training images by using the neural network model to obtain the plurality of target features. The first clustering module <NUM> performs the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features to obtain the plurality of first clustering results, where each of the plurality of first clustering results corresponds to one silhouette coefficient, and the silhouette coefficient indicates clustering quality. The determining module <NUM> determines the first target clustering result from the plurality of first clustering results based on a plurality of silhouette coefficients corresponding to the plurality of first clustering results, where the first target clustering result includes the M clustering categories. The second clustering module <NUM> performs second clustering processing on the plurality of training images based on the plurality of target features to obtain the second clustering result, and updates the parameter of the neural network model according to the first loss function, where the quantity of clustering categories included in the second clustering result is M. In the foregoing manner, an optimal quantity of clusters categories does not need to be determined by verifying, based on labeled samples, models corresponding to different obtained quantities of clustering categories, and the optimal quantity of clustering categories may be directly selected based on the first clustering result.

The following describes an execution device provided in an embodiment of this application. <FIG> is a schematic diagram of a structure of an execution device according to an embodiment of this application. An execution device <NUM> may be specifically presented as a virtual reality VR device, a mobile phone, a tablet, a notebook computer, an intelligent wearable device, a monitoring data processing device, or the like. This is not limited herein. Specifically, the execution device <NUM> includes a receiver <NUM>, a transmitter <NUM>, a processor <NUM>, and a memory <NUM> (there may be one or more processors <NUM> in the execution device <NUM>, and one processor is used as an example in <FIG>). The processor <NUM> may include an application processor <NUM> and a communication processor <NUM>. In some embodiments of this application, the receiver <NUM>, the transmitter <NUM>, the processor <NUM>, and the memory <NUM> may be connected through a bus or in another manner.

The memory <NUM> may include a read-only memory and a random access memory, and provide instructions and data to the processor <NUM>. A part of the memory <NUM> may further include a non-volatile random access memory (non-volatile random access memory, NVRAM). The memory <NUM> stores a processor and operation instructions, an executable module or a data structure, or a subset thereof, or an extended set thereof. The operation instructions may include various operation instructions used to implement various operations.

The processor <NUM> controls an operation of the execution device. In a specific application, all components of the execution device are coupled together by using a bus system. In addition to a data bus, the bus system may include a power bus, a control bus, a status signal bus, and the like. However, for clear description, various buses in the figure are referred to as the bus system.

The method disclosed in the foregoing embodiment of this application may be applied to the processor <NUM>, or may be implemented by the processor <NUM>. The processor <NUM> may be an integrated circuit chip and has a signal processing capability. In an implementation process, steps in the foregoing method may be implemented by using a hardware integrated logical circuit in the processor <NUM>, or by using instructions in a form of software. The processor <NUM> may be a general-purpose processor, a digital signal processor (digital signal processor, DSP), a microprocessor, or a microcontroller. The processor <NUM> may further include an application-specific integrated circuit (application-specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or another programmable logic device, a discrete gate, or a transistor logic device, or a discrete hardware component. The processor <NUM> may implement or perform the method, the steps, and the logical block diagrams disclosed in embodiments of this application. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor or the like. Steps of the method disclosed with reference to embodiments of this application may be directly executed and accomplished by using a hardware decoding processor, or may be executed and accomplished by using a combination of hardware and software modules in a 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, an electrically erasable programmable memory, or a register. The storage medium is located in the memory <NUM>, and the processor <NUM> reads information in the memory <NUM> and completes the steps in the foregoing method in combination with hardware of the processor <NUM>.

The receiver <NUM> may be configured to receive input digit or character information, and generate signal input related to related setting and function control of the execution device. The transmitter <NUM> may be configured to output digital or character information through a first interface. The transmitter <NUM> may be further configured to send instructions to a disk group through the first interface, to modify data in the disk group. The transmitter <NUM> may further include a display device such as a display screen.

In this embodiment of this application, in one case, the processor <NUM> is configured to perform the model update method performed by the execution device in the embodiment corresponding to <FIG>. Specifically, the application processor <NUM> may process image data based on the updated neural network model obtained in <FIG>.

An embodiment of this application further provides a training device. <FIG> is a schematic diagram of a structure of the training device according to an embodiment of this application. The model update apparatus described in the embodiment corresponding to <FIG> may be deployed on a training device <NUM>, to implement a function of the model update apparatus in the embodiment corresponding to <FIG>. Specifically, the training device <NUM> is implemented by one or more servers, and the training device <NUM> may differ greatly due to different configurations or performance. The training device <NUM> may include one or more central processing units (central processing units, CPU) <NUM> (for example, one or more processors) and a memory <NUM>, and one or more storage media <NUM> (for example, one or more mass storage devices) that store an application program <NUM> or data <NUM>. The memory <NUM> and the storage medium <NUM> may be transient storage or persistent storage. A program stored in the storage medium <NUM> may include at least one module (not shown in the figure), and each module may include a series of instruction operations for the training device. Further, the central processing unit <NUM> may be configured to: communicate with the storage medium <NUM>, and perform, on the training device <NUM>, the series of instruction operations in the storage medium <NUM>.

The training device <NUM> may further include one or more power supplies <NUM>, one or more wired or wireless network interfaces <NUM>, one or more input/output interfaces <NUM>, and/or one or more operating systems <NUM>, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, or FreeBSDTM.

In this embodiment of this application, the central processing unit <NUM> is configured to perform the model update method performed by the model update apparatus in the embodiment corresponding to <FIG>. Specifically, the central processing unit <NUM> is configured to:.

Optionally, the performing a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features includes:
performing the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features, and updating the parameter of the neural network model according to a second loss function after each time of first clustering processing.

Optionally, the updating the parameter of the neural network model according to a second loss function after each time of first clustering processing includes:
updating the parameter of the neural network model according to the second loss function after each time of first clustering processing, to reduce, in a first clustering result obtained after a next time of first clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the first clustering result.

Optionally, the plurality of times of first clustering processing include an ith time of clustering processing and a jth time of clustering processing; the jth time of clustering processing is after the ith time of clustering processing; and the performing a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features includes:.

Optionally, the performing a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features includes:.

Optionally, the updating a parameter of the neural network model according to a first loss function includes:
updating the parameter of the neural network model according to the triplet loss function and the second loss function, to reduce, in a second clustering result obtained after a next time of second clustering processing, a variance of first similarity distribution between each of the plurality of training images and a plurality of clustering categories included in the second clustering result, and increase a distance between different clustering categories in the second clustering result obtained after the next time of clustering processing.

This embodiment of this application provides the model update method. The method includes: obtaining the neural network model and the plurality of training images; performing feature extraction on the plurality of training images by using the neural network model to obtain the plurality of target features; performing the plurality of times of first clustering processing on the plurality of training images based on the plurality of target features to obtain the plurality of first clustering results, where each of the plurality of first clustering results corresponds to one silhouette coefficient, and the silhouette coefficient indicates clustering quality; determining the first target clustering result from the plurality of first clustering results based on a plurality of silhouette coefficient corresponding to the plurality of first clustering results, where the first target clustering result includes the M clustering categories; and performing second clustering processing on the plurality of training images based on the plurality of target features, to obtain the second clustering result, and updating the parameter of the neural network model according to the first loss function, where the quantity of clustering categories included in the second clustering result is M. In the foregoing manner, an optimal quantity of clusters categories does not need to be determined by verifying, based on labeled samples, models corresponding to different obtained quantities of clustering categories, and the optimal quantity of clustering categories may be directly selected based on the first clustering result.

An embodiment of this application further provides a computer program product. When the computer program product runs on a computer, the computer performs the steps performed by the execution device in the method described in the embodiment shown in <FIG>, or performs the steps performed by the training device in the method described in the embodiment shown in <FIG>.

An embodiment of this application further provides a computer-readable storage medium. The computer-readable storage medium stores a program used for signal processing. When the program runs on a computer, the computer performs the steps performed by the execution device in the method described in the embodiment shown in <FIG>, or performs the steps performed by the training device in the method described in the embodiment shown in <FIG>.

The execution device, the training device, or the terminal device provided in embodiments of this application may be specifically a chip. The chip includes a processing unit and a communication unit. 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. The processing unit may execute computer-executable instructions stored in a storage unit, so that a chip in the execution device performs the model update method described in the embodiment shown in <FIG>, or a chip in the training device performs the model update method described in the embodiment shown in <FIG>. Optionally, the storage unit is a storage unit in the chip, for example, a register or a cache. Alternatively, the storage unit may be a storage unit that is in a radio access device and that is located outside the chip, for example, a read-only memory (read-only memory, ROM), another type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM), or the like.

Specifically, <FIG> is a schematic diagram of a structure of a chip according to an embodiment of this application. The chip may be represented as a neural network processor NPU <NUM>. The NPU <NUM> is mounted to a host CPU (Host CPU) as a coprocessor, and the host CPU allocates a task for the NPU <NUM>. A core part of the NPU is an operation circuit <NUM>, and a controller <NUM> controls the operation circuit <NUM> to extract matrix data in a memory and perform a multiplication operation.

In some implementations, the operation circuit <NUM> internally includes a plurality of processing engines (Process Engine, PE). In some implementations, the operation circuit <NUM> is a two-dimensional systolic array. The operation circuit <NUM> may alternatively be a one-dimensional systolic array or another electronic circuit that can perform mathematical operations such as multiplication and addition. In some implementations, the operation circuit <NUM> is a general-purpose matrix processor.

For example, it is assumed that there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit fetches data corresponding to the matrix B from a weight memory <NUM>, and buffers the data on each PE in the operation circuit. The operation circuit fetches data of the matrix A from an input memory <NUM>, to perform a matrix operation on the matrix B, and stores an obtained partial result or an obtained final result of the matrix into an accumulator (accumulator) <NUM>.

A unified memory <NUM> is configured to store input data and output data. Weight data is directly transferred to the weight memory <NUM> by using a direct memory access controller (Direct Memory Access Controller, DMAC) <NUM>. The input data is also transferred to the unified memory <NUM> by using the DMAC.

BIU is the abbreviation for bus interface unit. A bus interface unit <NUM> is configured to perform interaction between an AXI bus, and the DMAC and an instruction fetch buffer (Instruction Fetch Buffer, IFB) <NUM>.

The bus interface unit <NUM> (Bus Interface Unit, BIU for short) is configured for the instruction fetch buffer <NUM> to obtain instructions from an external memory, and is further configured for the direct memory access controller <NUM> to obtain raw data of the input matrix A or the weight matrix B from the external memory.

The DMAC is mainly configured to transfer input data in the external memory DDR to the unified memory <NUM>, or transfer the weight data to the weight memory <NUM>, or transfer the input data to the input memory <NUM>.

A vector calculation unit <NUM> includes a plurality of operation processing units. When necessary, further processing is performed on output of the operation circuit, such as vector multiplication, vector addition, an exponential operation, a logarithmic operation, or value comparison. The vector calculation unit <NUM> is mainly configured to perform network computing, such as batch normalization (batch normalization), pixel-level summation, and upsampling of a feature plane, on a non-convolutional/fully-connected layer in a neural network.

In some implementations, the vector calculation unit <NUM> can store a processed output vector in the unified memory <NUM>. For example, the vector calculation unit <NUM> may apply a linear function or a non-linear function to the output of the operation circuit <NUM>, for example, perform linear interpolation on a feature plane extracted at a convolutional layer. For another example, the linear function or the non-linear function is applied to a vector of an accumulated value to generate an activation value. In some implementations, the vector calculation unit <NUM> generates a normalized value, a pixel-level sum, or a normalized value and a pixel-level sum. In some implementations, the processed output vector can be used as activation input of the operation circuit <NUM>, for example, to be used in a subsequent layer in the neural network.

The instruction fetch buffer (instruction fetch buffer) <NUM> connected to the controller <NUM> is configured to store instructions used by the controller <NUM>.

The unified memory <NUM>, the input memory <NUM>, the weight memory <NUM>, and the instruction fetch buffer <NUM> are all on-chip memories. The external memory is private to the NPU hardware architecture.

In addition, it should be noted that the described apparatus embodiment is merely an example. The units described as separate parts may or may not be physically separate; and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all the modules may be selected according to actual needs to achieve the objectives of the solutions of embodiments. In addition, in the accompanying drawings of the apparatus embodiments provided by this application, connection relationships between modules indicate that the modules have communication connections with each other, which may be specifically implemented as one or more communication buses or signal cables.

Based on the description of the foregoing implementations, a person skilled in the art may clearly understand that this application may be implemented by software in addition to necessary universal hardware, or by dedicated hardware, including a dedicated integrated circuit, a dedicated CPU, a dedicated memory, a dedicated component, and the like. Generally, any function that can be performed by a computer program can be easily implemented by using corresponding hardware. Moreover, a specific hardware structure used to achieve a same function may be in various forms, for example, in a form of an analog circuit, a digital circuit, or a dedicated circuit. However, for this application, a software program implementation is a better implementation in most cases. Based on such an understanding, the technical solutions of this application essentially or the part contributing to the conventional technology may be implemented in a form of a software product. The computer software product is stored in a readable storage medium, for example, a floppy disk, a USB flash drive, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disc of a computer, and includes several instructions for instructing a computer device (which may be a personal computer, a training device, or a network device) to perform the method described in embodiments of this application.

All or some of foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When the software is used to implement embodiments, all or some of embodiments may be implemented in a form of a computer program product.

Claim 1:
A model update method, wherein the method comprises:
obtaining (<NUM>) a neural network model and a plurality of training images;
performing (<NUM>) feature extraction on the plurality of training images by using the neural network model to obtain a plurality of target features;
performing (<NUM>) a plurality of times of first clustering processing on the plurality of training images based on the plurality of target features to obtain a plurality of first clustering results, wherein each of the plurality of first clustering results corresponds to one silhouette coefficient, and the silhouette coefficient indicates clustering quality;
determining (<NUM>) a first target clustering result from the plurality of first clustering results based on a plurality of silhouette coefficients corresponding to the plurality of first clustering results, wherein the first target clustering result comprises M clustering categories; and
performing (<NUM>) second clustering processing on the plurality of training images based on the plurality of target features to obtain a second clustering result, and updating a parameter of the neural network model according to a first loss function, wherein a quantity of clustering categories comprised in the second clustering result is M.