Typicality of Batches for Machine Learning

Systems and methods described herein can improve typicality of batches for machine learning. The systems and methods can include obtaining a corpus of training data, the corpus of training data including one or more training examples. The systems and methods can include generating a first batch set including a plurality of batches from the corpus of training data, each of the batches including a subset of the one or more training examples. The systems and methods can include determining a batch distribution of a first batch of the first batch set. The systems and methods can include determining that the first batch is an atypical batch based on the batch distribution of the first batch. The systems and methods can include, in response to determining that the first batch is an atypical batch, shuffling the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set. The systems and methods can include training a first machine-learned model using the second batch set.

FIELD

The present disclosure relates generally to training machine-learned models. More particularly, the present disclosure relates to improving typicality of batches of training examples used in training machine-learned models.

BACKGROUND

Machine-learned models are trained over training examples to perform some computational function. For instance, a training process can optimize parameters of the machine-learned model to best reflect the training examples. In some cases, training examples are separated into batches to facilitate training. Imbalances in these training example batches can negatively impact model training.

SUMMARY

One aspect of the present disclosure is directed to a computer-implemented method for training a machine-learned model. The computer-implemented method can include obtaining, by a computing system including one or more computing devices, a corpus of training data, the corpus of training data including one or more training examples. The computer-implemented method can include generating, by the computing system, a first batch set including a plurality of batches from the corpus of training data, each of the batches including a subset of the one or more training examples. The computer-implemented method can include determining, by the computing system, a batch distribution of a first batch of the first batch set. The computer-implemented method can include determining, by the computing system, that the first batch is an atypical batch based on the batch distribution of the first batch. The computer-implemented method can include, in response to determining that the first batch is an atypical batch, shuffling, by the computing system, the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set. The computer-implemented method can include training, by the computing system, a first machine-learned model using the second batch set.

Another example aspect is directed to a computing system. The computing system can include one or more processors and one or more non-transitory, computer-readable media storing instructions that, when implemented, cause the one or more processors to perform operations. The operations can include obtaining a corpus of training data, the corpus of training data including one or more training examples. The operations can include generating a first batch set including a plurality of batches from the corpus of training data, each of the batches including a subset of the one or more training examples. The operations can include determining a batch distribution of a first batch of the first batch set. The operations can include determining that the first batch is an atypical batch based on the batch distribution of the first batch. The operations can include, in response to determining that the first batch is an atypical batch, shuffling the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set. The operations can include training a first machine-learned model using the second batch set.

Another aspect of the present disclosure is directed to one or more non-transitory, computer-readable media storing instructions that, when implemented, cause one or more processors to perform operations. The operations can include obtaining a corpus of training data, the corpus of training data including one or more training examples. The operations can include generating a first batch set including a plurality of batches from the corpus of training data, each of the batches including a subset of the one or more training examples. The operations can include determining a batch distribution of a first batch of the first batch set. The operations can include determining that the first batch is an atypical batch based on the batch distribution of the first batch. The operations can include, in response to determining that the first batch is an atypical batch, shuffling the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set. The operations can include training a first machine-learned model using the second batch set.

DETAILED DESCRIPTION

Overview

Generally, the present disclosure is directed to ensuring typicality of batches of training examples used in training machine-learned models. A machine-learned model can be trained over a corpus of training data to predict solutions to algorithmic problems. For instance, machine-learned models can be trained to classify data into discrete categories, extrapolate data beyond an original set of training data, generate novel items based on patterns learned from the training data, and various other advanced computational tasks.

However, training a machine-learned model is not a computationally trivial task. Training machine-learned models commonly involves several iterations over thousands or even millions of training examples, depending on the problem. It can be computationally intractable to train machine-learned models on an entire corpus of training data at once. As such, machine-learned models are frequently trained over batches of training examples. Furthermore, due to size and memory constraints and requirements, many machine-learned models are trained with small batches, such as batches with as few as eight training examples. As used herein, a small batch can refer to any suitable batch, such as batches having a batch size of less than about thirty-two.

While smaller batches provide advantages regarding computing resource usage during the training process, smaller batches can result in larger variances in the gradient due to imbalances in the batch distributions. For example, atypical batches such as batches largely or entirely belonging to some homogenous population of the training data are statistically likely to occur over a large corpus of training data divided into small batches. As one example, a model trained with 1 million training steps and batch size eight is extremely likely to observe an entire batch sampled from some 5% of the training data (e.g., eight examples from the same class, such as eight cats in an animal classifier model). As another example, this model is extremely likely to observe a batch with a majority of the elements belonging to some 1% of the training data (e.g., in an animal classifier model, five or more white cats). These atypical batches can negatively impact the training process, especially in the case of non-convex optimization that is close to criticality. For instance, these atypical batches can negatively impact quality, speed, and/or stability of the training process.

Existing solutions to this problem assume that atypical batches are unavoidable and focus on mitigating damage from these atypical batches by techniques such as reduced learning rate and gradient clipping. However, these approaches introduce undesirable biases and effects into the training process. For example, reduced learning rate greatly slows down the training process. In addition, gradient clipping distorts the gradient in the case of atypical batches, which can introduce inaccuracies into the model, especially over a large set of examples. Furthermore, in many cases, computing the gradient for a given batch is a costly process. As such, it is computationally expensive to simply identify and discard atypical batches.

Systems and methods according to the present disclosure provide an improved solution for ensuring typicality of batches for machine-learning. In particular, the present disclosure provides a batch shuffling approach that reshuffles atypical batches with a number of other batches to create more balanced batches, especially small batches. Furthermore, the approaches according to the present disclosure can utilize existing data representations to determine whether a batch is typical or atypical, which can reduce computational resource wastage associated with computing gradients for atypical batches.

According to example aspects of the present disclosure, a computing system can obtain a corpus of training data including one or more training examples. The computing system can generate a first batch set including a plurality of batches from the corpus of training data. Each of the batches can include a subset of the one or more training examples. For instance, the first batch set can be a batch set generated by randomly allocating, slicing, or otherwise distributing the corpus of training data into the plurality of batches. Each of the plurality of batches can have a common batch size.

The computing system can determine a batch distribution of a first batch of the first batch set. The batch distribution can reflect the distribution of the training examples in the first batch. For instance, the batch distribution can have a mean and covariance representing the spread of training data in the batch. Determining the batch distribution can be computationally difficult, because the training data may be unlabeled or uncategorized such that information about the training data is not readily available. For instance, the batch distribution is often based on a solution to the problem that the machine-learned model is attempting to solve, especially in the case of unsupervised learning. Consider, for example, determining class distributions for training data when those classes are unknown.

According to example aspects of the present disclosure, the computing system can determine the batch distribution of the first batch based on existing representations of the corpus of training data. As used herein, an “existing representation” of the corpus of training data refers to any representation of the corpus of training data, including the corpus of training data itself, that is derivable from the corpus of training data by an approach other than the use of the machine-learned model to be trained. As another example, an existing representation of the corpus of training data can be knowable at the time of training the machine-learned model. For instance, the existing representation may be known, derived, or learned by an approach that is less computationally intensive than training the machine-learned model and prior to training the machine-learned model. The existing representation(s) may be related to, but not necessarily identical to, eventual outputs of the machine-learned model.

One example of existing representations of the corpus of training data includes outputs of a second machine-learned model in response to receiving as input the corpus of training data. For instance, the second machine-learned model can generate outputs that are useful for identifying atypical distributions in the batches of training data. The second machine-learned model can perform a similar or even identical task to the first machine-learned model. For instance, the second machine-learned model may be a prior version of the first machine-learned model, such that the outputs from the second machine-learned model are reflective of the eventual outputs of the first machine-learned model and therefore useful for determining distributions in the training data. As another example, the second machine-learned model may be a model that performs a more general version of the task performed by the first machine-learned model. As one example, if the first machine-learned model is trained for a specific classification task, the second machine-learned model may perform a more general classification task. As another example, if the first model is a semantic analysis model trained on a specific category of speech, the second model may be a general or off-the-shelf semantic analysis model. Thus, the second machine-learned model can be useful for identifying atypical batches, even if the first machine-learned model will ultimately have improved accuracy, efficiency, specificity, etc. compared to the second machine-learned model.

The computing system can then determine that the first batch is an atypical batch based on the batch distribution of the first batch. For instance, in some implementations, the computing system can compare the batch distribution of the first batch to a corpus distribution representing the corpus of training data. For instance, in one example implementation, the computing system can determine a typicality score for the first batch based on a similarity between the corpus distribution and the batch distribution of the first batch. The computing system can determine whether the first batch is an atypical batch based on the typicality score. For instance, the typicality score can be compared to a typicality score threshold that, if satisfied, indicates that the batch is typical. One example typicality score is based on a divergence, such as a Kullback-Leibler (KL) divergence, between the batch distribution and the corpus distribution. Although the batch distribution of the first batch does not necessarily have to exactly match the corpus distribution, a highly dissimilar batch distribution can reflect an atypical batch. For example, if a batch distribution is highly skewed towards a subset of training data reflecting some commonality (e.g., a common class) that is not present in the overall training data, training the machine-learned model on that batch may negatively impact the performance of the machine-learned model.

In response to determining that the first batch is an atypical batch, the computing system can shuffle the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set. The computing system can then train the machine-learned model using the second batch set. For instance, in some implementations, the computing system can aggregate and redistribute the training examples in the first batch and the second batches to disperse the atypical homogeneity of the first batch across a larger set of batches, which can desirably improve the overall typicality of the batches. As another example, in some implementations, the computing system can randomly swap one or more training examples between two or more batches to generate the second batch set.

In some implementations, the computing system can shuffle the training examples more than once to improve typicality of the batches. For example, if the computing system that the corresponding batch in the second batch set is still atypical, the computing system can reshuffle the second batch set (e.g., until the corresponding batch is typical). In some implementations, the computing system may increase the number of batches included in the shuffling (e.g., increase a number of second batches) with each consecutive reshuffle.

Example aspects of the present disclosure provide for a number of technical effects and benefits, including improvements to computing technologies. For instance, systems and methods according to example aspects of the present disclosure can determine a batch distribution of a first batch, determining that the first batch is an atypical batch based on the batch distribution, shuffle the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set, and train a machine-learned model using the second batch set. Shuffling the training examples of the first (atypical) batch and the second batches can disperse the concentrated examples across a larger set of batches, which can improve heterogeneity of the second batch set compared to the first batch set. This, in turn, can reduce variance in the gradients determined from the second batch set during training of the machine-learned model. As a result, the training process for the machine-learned model is improved by avoiding the detrimental effects to quality, speed, and stability resulting from training over the atypical batches.

Furthermore, according to example aspects of the present disclosure, existing representations of the training data can be used for determining that the first batch is an atypical batch, such as for determining the batch distribution, which can reduce computational resource wastage associated with determining the gradient for atypical batches. In particular, using the existing representations of a batch, such as model outputs from a prior version of the machine-learned model or from a different model that performs a similar task in response to receiving the batch as input, can be cheaper to determine and use than a gradient for the batch while still adequately representing the distribution for the batch.

Example Devices and Systems

FIG.1Adepicts a block diagram of an example computing system100that performs machine-learning according to example embodiments of the present disclosure. The system100includes a user computing device102, a server computing system130, and a training computing system150that are communicatively coupled over a network180.

In some implementations, the user computing device102can store or include one or more machine-learned models120. For example, the machine-learned models120can be or can otherwise include various machine-learned models such as neural networks (e.g., deep neural networks) or other types of machine-learned models, including non-linear models and/or linear models. Neural networks can include feed-forward neural networks, recurrent neural networks (e.g., long short-term memory recurrent neural networks), convolutional neural networks or other forms of neural networks. Some example machine-learned models can leverage an attention mechanism such as self-attention. For example, some example machine-learned models can include multi-headed self-attention models (e.g., transformer models).

In some implementations, the one or more machine-learned models120can be received from the server computing system130over network180, stored in the user computing device memory114, and then used or otherwise implemented by the one or more processors112. In some implementations, the user computing device102can implement multiple parallel instances of a single machine-learned model120.

Additionally or alternatively, one or more machine-learned models140can be included in or otherwise stored and implemented by the server computing system130that communicates with the user computing device102according to a client-server relationship. For example, the machine-learned models140can be implemented by the server computing system140as a portion of a web service. Thus, one or more models120can be stored and implemented at the user computing device102and/or one or more models140can be stored and implemented at the server computing system130.

The user computing device102can also include one or more user input components122that receives user input. For example, the user input component122can be a touch-sensitive component (e.g., a touch-sensitive display screen or a touch pad) that is sensitive to the touch of a user input object (e.g., a finger or a stylus). The touch-sensitive component can serve to implement a virtual keyboard. Other example user input components include a microphone, a traditional keyboard, or other means by which a user can provide user input.

As described above, the server computing system130can store or otherwise include one or more machine-learned models140. For example, the models140can be or can otherwise include various machine-learned models. Example machine-learned models include neural networks or other multi-layer non-linear models. Example neural networks include feed forward neural networks, deep neural networks, recurrent neural networks, and convolutional neural networks. Some example machine-learned models can leverage an attention mechanism such as self-attention. For example, some example machine-learned models can include multi-headed self-attention models (e.g., transformer models).

The user computing device102and/or the server computing system130can train the models120and/or140via interaction with the training computing system150that is communicatively coupled over the network180. The training computing system150can be separate from the server computing system130or can be a portion of the server computing system130.

The training computing system150can include a model trainer160that trains the machine-learned models120and/or140stored at the user computing device102and/or the server computing system130using various training or learning techniques, such as, for example, backwards propagation of errors. For example, a loss function can be backpropagated through the model(s) to update one or more parameters of the model(s) (e.g., based on a gradient of the loss function). Various loss functions can be used such as mean squared error, likelihood loss, cross entropy loss, hinge loss, and/or various other loss functions. Gradient descent techniques can be used to iteratively update the parameters over a number of training iterations.

In particular, the model trainer160can train the machine-learned models120and/or140based on a set of training data162. The training data162can include, for example, a corpus of training data. The training data162can be partitioned into a plurality of batches. The batches can be small batches, such as batches having a batch size of less than sixteen training examples per batch.

In some implementations, if the user has provided consent, the training examples can be provided by the user computing device102. Thus, in such implementations, the model120provided to the user computing device102can be trained by the training computing system150on user-specific data received from the user computing device102. In some instances, this process can be referred to as personalizing the model.

The machine-learned models described in this specification may be used in a variety of tasks, applications, and/or use cases.

In some implementations, the input to the machine-learned model(s) of the present disclosure can be image data. The machine-learned model(s) can process the image data to generate an output. As an example, the machine-learned model(s) can process the image data to generate an image recognition output (e.g., a recognition of the image data, a latent embedding of the image data, an encoded representation of the image data, a hash of the image data, etc.). As another example, the machine-learned model(s) can process the image data to generate an image segmentation output. As another example, the machine-learned model(s) can process the image data to generate an image classification output. As another example, the machine-learned model(s) can process the image data to generate an image data modification output (e.g., an alteration of the image data, etc.). As another example, the machine-learned model(s) can process the image data to generate an encoded image data output (e.g., an encoded and/or compressed representation of the image data, etc.). As another example, the machine-learned model(s) can process the image data to generate an upscaled image data output. As another example, the machine-learned model(s) can process the image data to generate a prediction output.

In some implementations, the input to the machine-learned model(s) of the present disclosure can be text or natural language data. The machine-learned model(s) can process the text or natural language data to generate an output. As an example, the machine-learned model(s) can process the natural language data to generate a language encoding output. As another example, the machine-learned model(s) can process the text or natural language data to generate a latent text embedding output. As another example, the machine-learned model(s) can process the text or natural language data to generate a translation output. As another example, the machine-learned model(s) can process the text or natural language data to generate a classification output. As another example, the machine-learned model(s) can process the text or natural language data to generate a textual segmentation output. As another example, the machine-learned model(s) can process the text or natural language data to generate a semantic intent output. As another example, the machine-learned model(s) can process the text or natural language data to generate an upscaled text or natural language output (e.g., text or natural language data that is higher quality than the input text or natural language, etc.). As another example, the machine-learned model(s) can process the text or natural language data to generate a prediction output.

In some implementations, the input to the machine-learned model(s) of the present disclosure can be speech data. The machine-learned model(s) can process the speech data to generate an output. As an example, the machine-learned model(s) can process the speech data to generate a speech recognition output. As another example, the machine-learned model(s) can process the speech data to generate a speech translation output. As another example, the machine-learned model(s) can process the speech data to generate a latent embedding output. As another example, the machine-learned model(s) can process the speech data to generate an encoded speech output (e.g., an encoded and/or compressed representation of the speech data, etc.). As another example, the machine-learned model(s) can process the speech data to generate an upscaled speech output (e.g., speech data that is higher quality than the input speech data, etc.). As another example, the machine-learned model(s) can process the speech data to generate a textual representation output (e.g., a textual representation of the input speech data, etc.). As another example, the machine-learned model(s) can process the speech data to generate a prediction output.

In some implementations, the input to the machine-learned model(s) of the present disclosure can be latent encoding data (e.g., a latent space representation of an input, etc.). The machine-learned model(s) can process the latent encoding data to generate an output. As an example, the machine-learned model(s) can process the latent encoding data to generate a recognition output. As another example, the machine-learned model(s) can process the latent encoding data to generate a reconstruction output. As another example, the machine-learned model(s) can process the latent encoding data to generate a search output. As another example, the machine-learned model(s) can process the latent encoding data to generate a reclustering output. As another example, the machine-learned model(s) can process the latent encoding data to generate a prediction output.

In some implementations, the input to the machine-learned model(s) of the present disclosure can be statistical data. Statistical data can be, represent, or otherwise include data computed and/or calculated from some other data source. The machine-learned model(s) can process the statistical data to generate an output. As an example, the machine-learned model(s) can process the statistical data to generate a recognition output. As another example, the machine-learned model(s) can process the statistical data to generate a prediction output. As another example, the machine-learned model(s) can process the statistical data to generate a classification output. As another example, the machine-learned model(s) can process the statistical data to generate a segmentation output. As another example, the machine-learned model(s) can process the statistical data to generate a visualization output. As another example, the machine-learned model(s) can process the statistical data to generate a diagnostic output.

In some implementations, the input to the machine-learned model(s) of the present disclosure can be sensor data. The machine-learned model(s) can process the sensor data to generate an output. As an example, the machine-learned model(s) can process the sensor data to generate a recognition output. As another example, the machine-learned model(s) can process the sensor data to generate a prediction output. As another example, the machine-learned model(s) can process the sensor data to generate a classification output. As another example, the machine-learned model(s) can process the sensor data to generate a segmentation output. As another example, the machine-learned model(s) can process the sensor data to generate a visualization output. As another example, the machine-learned model(s) can process the sensor data to generate a diagnostic output. As another example, the machine-learned model(s) can process the sensor data to generate a detection output.

In some cases, the machine-learned model(s) can be configured to perform a task that includes encoding input data for reliable and/or efficient transmission or storage (and/or corresponding decoding). For example, the task may be an audio compression task. The input may include audio data and the output may comprise compressed audio data. In another example, the input includes visual data (e.g. one or more images or videos), the output comprises compressed visual data, and the task is a visual data compression task. In another example, the task may comprise generating an embedding for input data (e.g. input audio or visual data).

In some cases, the input includes audio data representing a spoken utterance and the task is a speech recognition task. The output may comprise a text output which is mapped to the spoken utterance. In some cases, the task comprises encrypting or decrypting input data. In some cases, the task comprises a microprocessor performance task, such as branch prediction or memory address translation.

FIG.1Bdepicts a block diagram of an example computing device10that performs machine-learning according to example embodiments of the present disclosure. The computing device10can be a user computing device or a server computing device.

The computing device10includes a number of applications (e.g., applications1through N). Each application contains its own machine learning library and machine-learned model(s). For example, each application can include a machine-learned model. Example applications include a text messaging application, an email application, a dictation application, a virtual keyboard application, a browser application, etc.

FIG.1Cdepicts a block diagram of an example computing device50that performs machine-learning according to example embodiments of the present disclosure. The computing device50can be a user computing device or a server computing device.

The computing device50includes a number of applications (e.g., applications1through N). Each application is in communication with a central intelligence layer. Example applications include a text messaging application, an email application, a dictation application, a virtual keyboard application, a browser application, etc. In some implementations, each application can communicate with the central intelligence layer (and model(s) stored therein) using an API (e.g., a common API across all applications).

FIG.2depicts a block diagram of an example machine-learned model200according to example embodiments of the present disclosure. In some implementations, the machine-learned model200is trained to receive a set of input data204and, as a result of receipt of the input data204, provide output data206that predicts an output according to a computational task based on the input data204. For instance, the output data206can include a classification for the input data204, a generative output based on the input data204, and/or any other suitable types of output.

FIG.3depicts a diagram of training data distributions according to example embodiments of the present disclosure. In particular, a corpus of training data302can include a plurality of training examples304. The training examples304can include data having some characteristic over which a corpus distribution306exists. The characteristic can be, for example, a ground truth output associated with a machine-learned model when the example304is input to the machine-learned model. The characteristic may or may not be known for the corpus of training data302. For instance, if the corpus302includes supervised data, the examples304may be labeled with appropriate ground truth outputs. If, however, the corpus302includes unsupervised data, the examples304may not be labeled with data over which the corpus distribution306can be generated.

To train a machine-learned model, the corpus of training data302can be partitioned into a first batch set310including a plurality of batches312,314,316. It should be understood that a corpus of training data can include thousands and even millions of training examples and may be partitioned into greater than three batches. For instance, a corpus may be partitioned into small batches having fewer than sixteen training examples304per batch, which may produce thousands or millions of batches in a batch set. Each of the batches312,314,316can include a plurality of training examples304.

Furthermore, each of the batches in the first batch set310can have an associated batch distribution. For instance, first batch distribution313can be associated with first batch312. Similarly, second batch distribution315can be associated with second batch314and/or third batch distribution317can be associated with third batch316. The batch distributions313,315,317reflect the makeup of their respective batch. As illustrated inFIG.3, the first batch313can be an atypical batch having a first batch distribution315that differs from the batch distribution306. It should be understood that the visual similarity or difference of batch distributions is not necessarily an indicator of batch typicality or atypicality, and is used herein for the purposes of illustration.

If the distributions306,313,315,317are not readily available (e.g., in the case of unsupervised data), a distribution model330can generate existing representations of the corpus of training data302and/or the batches310that can be used to determine the distributions. For instance, the distribution model330can be a machine-learned model. If the corpus of training data302will be used to train a machine-learned model, that model can be different from the distribution model330. For instance, the distribution model330can produce the existing representation in response to receiving the examples304as input. As one example, the existing representation can be an embedding, a classification, a compressed representation, or other suitable representation produced by a distribution model330. In some implementations, the distribution model330can be configured to perform a similar task to the machine-learned model that will be trained using the corpus of training data302. As one example, the distribution model330and the machine-learned model can be configured for a common task, such as an image classification task, a regression task, or other suitable task. Although the machine-learned model and the distribution model330can perform a common task, they can nonetheless be distinct models. Generally, the outputs of the first machine-learned model and the distribution model330can have enough commonality such that outputs of the distribution model330can be somewhat correlated to outputs of the first machine-learned model.

FIG.4depicts a diagram of shuffling training examples according to example embodiments of the present disclosure. For instance,FIG.4depicts how the first batch set310can be shuffled into a second batch set410having batches412,414, and416, each with respective distributions413,415, and417. For instance, in the example ofFIG.4, training examples422and424are swapped between batches412and414and training examples432and434are swapped between batches412and416. As illustrated, the batches in second batch set410have distributions that each somewhat reflect the corpus distribution306and are not atypical. For instance, swapping some examples from the more-homogenous first batch412with the less-homogenous batches414and416can improve the degree to which the first batch412matches the corpus distribution306. In this way, the second batch set410can provide improved training characteristics for a machine-learned model.

FIG.5depicts a diagram of an example system500for training a machine-learned model540according to example embodiments of the present disclosure. The system500can obtain a corpus of training data502. The system500can populate a batch buffer510using the corpus of training data502. For instance, the batch buffer510can partition the training examples of the corpus502into a first batch set520, which can be stored in the batch buffer510at a first point in time. The first batch set520can include batches522,524, and526, of which batch522is an atypical batch.

The system500can determine that the first batch522is an atypical batch as described herein. In response to determining that the first batch522is an atypical batch, the system500can shuffle the training examples of the first batch522with one or more second batches (e.g., batches524,526) to produce a second batch set530. For instance, the batch buffer510can overwrite the first batch set520with the second batch set530. The second batch set530can include shuffled batches532,534, and536. The shuffled batches532,534,536can have no atypical batches. The second batch set530can then be used to train the machine-learned model540. Although two batches are shuffled with the atypical batch in the example illustrated inFIG.5, it should be understood that the atypical batch can be shuffled with more or fewer batches without departing from the present disclosure.

Example Methods

FIG.6depicts a flow chart diagram of an example method600to train a machine-learned model according to example embodiments of the present disclosure. AlthoughFIG.6depicts steps performed in a particular order for purposes of illustration and discussion, the methods of the present disclosure are not limited to the particularly illustrated order or arrangement. The various steps of the method600can be omitted, rearranged, combined, and/or adapted in various ways without deviating from the scope of the present disclosure.

At602, a computing system can obtain a corpus of training data. The corpus of training data can include one or more training examples. Example aspects of the present disclosure contemplate any suitable form and manner of training data. For instance, the corpus of training data can include labeled data, such as data labeled with an expected output. Additionally or alternatively, the corpus of training data can include unlabeled data. The data can be, for example, images, audio files, video files, numerical data, statistical data, embedding data, natural language data, speech data, text data, and/or any other suitable data.

At604, the computing system can generate a first batch set including a plurality of batches from the corpus of training data. Each of the batches can be or can include a subset of the one or more training examples. For instance, in some implementations, the computing system can partition the corpus of training data into a plurality of (e.g., equally-sized) batches. The batches can be small batches, such as batches having a batch size of less than sixteen training examples per batch. The computing system can generate the first batch set by any suitable manner, such as randomly partitioning the corpus of training data, splitting the corpus of training data according to an ordering of the corpus of training data, or any other suitable manner.

At606, the computing system can determine a batch distribution of a first batch of the first batch set. According to example aspects of the present disclosure, determining the batch distribution of the first batch can be based on existing representations of the corpus of training data. For instance, in some implementations, the existing representations of the corpus of training data can include outputs of a second machine-learned model in response to receiving as input the corpus of training data. For instance, the second machine-learned model can produce the existing representation of the corpus of training data in response to receiving the corpus of training data (or portion thereof) as input. As one example, the existing representation can be an embedding, a classification, a compressed representation, or other suitable representation produced by a second machine-learned model. In some implementations, the second machine-learned model can be configured to perform a similar task to the first machine-learned model. As one example, the second machine-learned model and the first machine-learned model can be configured for a common task, such as an image classification task, a regression task, or other suitable task.

Although the first machine-learned model and the second machine-learned model can perform a common task, they can nonetheless be distinct models. Generally, the outputs of the first machine-learned model and the second machine-learned model can have enough commonality such that outputs of the second machine-learned model can be somewhat correlated to outputs of the first machine-learned model. In this manner, the outputs of the second machine-learned model can serve as an effective “pseudo-truth” for determining the distribution of the first batch without requiring costly algorithms to determine the true distribution of the first batch, when the distribution is unavailable. In some example implementations, the second machine-learned model can be or can include a prior version of the first machine-learned model. For instance, if a machine-learned model is updated yearly, the second machine-learned model may be a version of the machine-learned model from a prior year.

At608, the computing system can determine that the first batch is an atypical batch based on the batch distribution of the first batch. An atypical batch can be a batch having some undesirable degree of homogeneity. For example, if a machine-learned model is trained to perform a classification task that classifies data between one of fifty classes and a batch has nearly all of its training examples belonging to a single class, that batch can be an atypical batch.

Furthermore, in some implementations, determining that the first batch is an atypical batch can be performed based on a comparison between a corpus distribution of the corpus of training data and the batch distribution of the first batch. For instance, if the distribution of the first batch differs from the overall distribution of the training data, the first batch may be atypical. As one example, in some implementations, the computing system can further determine a corpus distribution of the corpus of training data. In some implementations, the corpus distribution can be determined based on the entire corpus of training data. Additionally or alternatively, in some implementations, the corpus distribution can be determined based on a subset of the corpus of training data.

In some implementations, determining that the first batch is an atypical batch can be based on a typicality score associated with the first batch. For instance, the typicality score can be a value within a range of values, wherein the range indicates how similar the distribution of the first batch is to the corpus distribution. For instance, in some implementations, determining that the first batch is an atypical batch based on the batch distribution of the first batch can include determining, by the computing system, a typicality score for the first batch based on the batch distribution of the first batch and the corpus distribution. Additionally or alternatively, determining that the first batch is an atypical batch based on the batch distribution of the first batch can include determining that the first batch is an atypical batch based on the typicality score for the first batch.

In some implementations, determining that the first batch is an atypical batch based on the typicality score for the first batch includes comparing the typicality score for the first batch to a typicality score threshold. For instance, the typicality score threshold can be a threshold indicating whether a batch is considered typical or atypical. As an example, the typicality score threshold can have a value falling within a range of possible values of the typicality score. Typicality score values on one side of the typicality score threshold can indicate typical batches and typicality score values on the other side of the typicality score threshold can indicate atypical batches.

In some implementations, the typicality score can be based on a divergence between the batch distribution of the first batch and the corpus distribution. For instance, any suitable divergence can be used to measure a distance or dissimilarity between the batch distribution and the corpus distribution. In some implementations, for example, the divergence can be or can include a Kullback-Leibler (KL) divergence, a Jensen-Shannon divergence, and/or other suitable divergences. In addition to and/or alternatively to divergences, the typicality score can be based on any other suitable manner of determining similarity between distributions, such as, for example, the Kolmogorov-Smirnov test.

At610, the computing system can (e.g., in response to determining that the first batch is an atypical batch) shuffle the training examples of the first batch and one or more second batches of the first batch set to generate a second batch set. For instance, the computing system can distribute at least some of the training examples of the first batch among the second batches and/or replace the distributed training examples of the first batch with training examples from the second batches to shuffle the training examples. The shuffled training examples can be recombined into shuffled batches which are ultimately used to generate the second batch set. Two example approaches for shuffling the training examples are described with respect toFIGS.7and8. Any other suitable approaches for shuffling the training examples can be used in accordance with the present disclosure.

At612, the computing system can train a first machine-learned model using the second batch set. For instance, the second batch set can replace the first batch set for training the first machine-learned model. Each of the batches in the second batch set can be provided to the first machine-learned model as training data over one or more epochs. The first machine-learned model can be trained by various training or learning techniques, such as, for example, backwards propagation of errors. For example, a loss function (e.g., for each batch) can be backpropagated through the model(s) to update one or more parameters of the model(s) (e.g., based on a gradient of the loss function). Various loss functions can be used such as mean squared error, likelihood loss, cross entropy loss, hinge loss, and/or various other loss functions. Gradient descent techniques can be used to iteratively update the parameters over a number of training iterations.

FIG.7depicts a flow chart diagram of an example method700to perform shuffling training examples of a first batch and one or more second batches of a batch set according to example embodiments of the present disclosure. AlthoughFIG.7depicts steps performed in a particular order for purposes of illustration and discussion, the methods of the present disclosure are not limited to the particularly illustrated order or arrangement. The various steps of the method700can be omitted, rearranged, combined, and/or adapted in various ways without deviating from the scope of the present disclosure.

At702, a computing system can select a first training example from the first batch. The computing system can select the first training example in any suitable manner. As one example, in some implementations, the computing system can randomly select the first training example. As another example, in some implementations, the computing system can select the first training example according to an ordering of the first batch.

At704, the computing system can select a second training example from a second batch of one or more second batches. As one example, in some implementations, the computing system can randomly select the second training example. As another example, in some implementations, the computing system can select the second training example according to an ordering of the second batch.

At706, the computing system can swap the first training example and the second training example. For instance, the computing system can store the first training example at a memory location different from the first batch or the second batch. The computing system can then overwrite the first training example at the first batch with the second training example. Finally, the computing system can overwrite the second training example at the second batch with the first training example from the memory location different from the first batch or the second batch.

The method700can be repeated one or more times to shuffle multiple training examples among the batches. For example, in some implementations, the computing system can repeat the method700until the first batch is no longer determined to be an atypical batch. In this way, the computing system can ensure the typicality of the training data used to train a machine-learned model.

FIG.8depicts a flow chart diagram of an example method800to perform shuffling training examples of a first batch and one or more second batches of a batch set according to example embodiments of the present disclosure. AlthoughFIG.8depicts steps performed in a particular order for purposes of illustration and discussion, the methods of the present disclosure are not limited to the particularly illustrated order or arrangement. The various steps of the method800can be omitted, rearranged, combined, and/or adapted in various ways without deviating from the scope of the present disclosure.

At802, a computing system can aggregate the training examples of the first batch and the one or more second batches into an example set. For instance, the example set can store the examples of each of the batches in a permutable structure, such as a tensor. The example set can store the values or data associated with the training example directly, in some implementations. Additionally or alternatively, in some implementations, the example set can store addresses or pointers for the training examples in the example set. At804, the computing system can permute an order of the training examples in the example set. Furthermore, at806, the computing system can redistribute the training examples in the example set among the first batch and the one or more second batches according to the order to generate a batch set (e.g., the second batch set). For instance, in some implementations, the computing system can swap positions of one or more training examples in the example set and partition the example set into corresponding batches based on the swapped positions of the training examples. As another example, in some implementations, the computing system can assign training examples to new batches corresponding to the first batch and the one or more second batches.

ADDITIONAL DISCLOSURE