Patent Description:
Machine learning models receive an input and generate an output, e.g., a predicted output, based on the received input. Some machine learning models are parametric models and generate the output based on the received input and on values of the parameters of the model.

Some machine learning models are deep models that employ multiple layers of models to generate an output for a received input. For example, a deep neural network is a deep machine learning model that includes an output layer and one or more hidden layers that each apply a non-linear transformation to a received input to generate an output.

Some neural networks are recurrent neural networks. A recurrent neural network is a neural network that receives an input sequence and generates an output sequence from the input sequence. In particular, a recurrent neural network uses some or all of the internal state of the network after processing a previous input in the input sequence in generating an output from the current input in the input sequence. <NPL>, describes software tools for developing deep learning models. <NPL>), describes a hybrid textural-visual programming platform for developing deep learning models. A toolbox for designing neural networks is specified in <NPL>.

According to first, second and third aspects of the present invention, there is provided a computer-implemented method as defined in claim <NUM>, one or more computer storage media encoded with instructions as defined in claim <NUM> and a system as defined in claim <NUM>. This specification describes how a system implemented as computer programs on one or more computers in one or more locations can augment a computational graph representing neural network operations with operations performed by a different, separately trained neural network.

A user computational graph can be augmented with a trained neural network such that, when the system executes the user computational graph, the operations of the trained neural network are performed at the appropriate points during execution, but the architecture and trained parameter values of the trained neural network are not transparent to the user. Accordingly, the system can offer functionality of a library of pre-trained neural networks without disclosing to users of the system the details of the operation of the neural networks. This may make the process of the user interacting with the system to specify the user computational graph, more straightforward and less time-consuming, since the user does not have to specify low-level neural structure within the user computational graph to carry out the functions performed by the pre-trained network. Thus, the disclosure makes possible an improved user interface.

Moreover, because the neural networks may have already been fully or partially trained, the system can reduce the computational resources necessary to train user neural networks, i.e., because multiple user computational graphs can make use of the same trained neural network without needing to re-train the trained neural network from scratch for each user.

Moreover, by incorporating pre-trained state-of-the-art neural networks into user computational graphs, the performance of the user neural networks can be improved without the system needing to allocate additional resources to training the user neural networks or needing to transmit large amounts of data, i.e., training data, over the network to and from the users.

This specification generally describes a computational graph system that maintains machine learning models as computational graphs.

A computational graph includes nodes connected by directed edges. Each node in the computational graph represents an operation. An incoming edge to a node represents a flow of an input into the node, i.e., an input to the operation represented by the node. An outgoing edge from a node represents a flow of an output of the operation represented by the node to be used as an input to an operation represented by another node. Thus, a directed edge connecting a first node in the graph to a second node in the graph indicates that an output generated by the operation represented by the first node is used as an input to the operation represented by the second node.

Generally, the input and outputs flowing along directed edges in the computational graph are tensors. A tensor is a multidimensional array of numeric or other values, e.g., strings, having a specific order that corresponds to the dimensionality of the array. For example, a scalar value is a 0th-order tensor, a vector of numeric values is a 1st-order tensor, and a matrix is a 2nd-order tensor.

As indicated above, the operations represented in a given computational graph are neural network operations or operations for a different kind of machine leaming model. A neural network is a machine learning model that employs one or more layers of nonlinear units to predict an output for a received input. Some neural networks are deep neural networks that include one or more hidden layers in addition to an output layer. The output of each hidden layer is used as input to another layer in the network, i.e., another hidden layer, the output layer, or both. Some layers of the network generate an output from a received input in accordance with current values of a respective set of parameters, while other layers of the network may not have parameters.

For example, the operations represented by the computational graph may be operations necessary for the neural network to compute an inference, i.e., to process an input through the layers of the neural network to generate a neural network output for the input. As another example, the operations represented by the computational graph may be operations necessary to train the neural network by performing a neural network training procedure to adjust the values of the parameters of the neural network, e.g., to determine trained values of the parameters from initial values of the parameters. In some cases, e.g., during training of the neural network, the operations represented by the computational graph can include operations performed by multiple replicas of the neural network.

By way of illustration, a neural network layer that receives an input from a previous layer can use a parameter matrix to perform a matrix multiplication between the parameter matrix and the input. In some cases, this matrix multiplication can be represented as multiple nodes in the computational graph. For example, a matrix multiplication can be divided into multiple multiplication and addition operations, and each operation can be represented by a different node in the computational graph. The operation represented by each node can generate a respective output, which flows on a directed edge to a subsequent node. After the operation represented by a final node generates a result of the matrix multiplication, the result flows, on a directed edge, to another node. The result is equivalent to an output of the neural network layer that performs the matrix multiplication.

In some other cases, the matrix multiplication is represented as one node in the graph. The operations represented by the node can receive, as inputs, an input tensor on a first directed edge and a weight tensor, e.g., a parameter matrix, on a second directed edge. The node can process, e.g., perform a matrix multiplication of, the input and weight tensors to output, on a third directed edge, an output tensor, which is equivalent to an output of the neural network layer.

Other neural network operations that may be represented by nodes in the computational graph include other mathematical operations, e.g., subtraction, division, and gradient computations; array operations, e.g., concatenate, splice, split, or rank; and neural network building block operations, e.g., SoftMax, Sigmoid, rectified linear unit (ReLU), or convolutions.

<FIG> shows an example computational graph system <NUM>. The system <NUM> is an example of a system implemented as computer programs on one or more computers in one or more locations, in which the systems, components, and techniques described below can be implemented.

Generally, the computational graph system <NUM> maintains user computational graphs <NUM> and executes the user computational graphs on devices available to the system, e.g., devices <NUM>-<NUM>. The devices <NUM>-<NUM> can be any of a variety of devices capable of performing neural network operations, e.g., Graphical Processing Units (GPUs), Central Processing Units (CPUs), or special-purpose neural network hardware accelerators.

For example, the system <NUM> can maintain a framework that allows users to create and upload computational graphs representing neural network operations for execution by the system <NUM>. An example of a framework that specifies neural network operations as computational graphs is the TensorFlow framework, described in <NPL>.

A user of a user device <NUM> can request, e.g., using the framework and over a data communication network <NUM>, operations to be performed on a computational graph representing neural network operations. To perform these operations, the computational graph is executed. As part of the request, the user device <NUM> provides data identifying a computational graph to the system <NUM>, i.e., identifying a particular computational graph from the maintained user computational graphs <NUM> or a new computational graph to be added to the maintained user computational graphs <NUM>, and specifies types of operations to be performed on the computational graph.

For example, the request can identify a computational graph representing operations necessary to perform an inference for a particular neural network, i.e., to generate an output using the particular neural network, and can identify an input on which the inference should be performed.

As another example, the request can identify a computational graph representing a training procedure for a particular neural network and can identify an input, i.e., training data, on which the training should be performed. That is, the graph includes operations necessary to perform an inference using the particular neural network as well as operations necessary to determine updates to the parameters of the neural network using the training procedure. In this example, when receiving a request to process a computational graph representing a training procedure, the system <NUM> can determine modified values for parameters of the neural network by executing the computational graph.

In some cases, the request may specify a response that should be transmitted in response to the request. For example, for a neural network training request, the user device <NUM> can request an indication that the requested neural network training operations have been completed and, optionally, trained values of the parameters of the neural network or an indication of a memory location from which the trained values can be accessed by the user device <NUM>. As another example, for a neural network inference request, the user device <NUM> can request output values that represent an inference operation from one or more particular output nodes of the identified computational graph.

The system <NUM> can then execute the request, i.e., by executing the identified computational graph on the identified inputs, and, if requested, provide the response to the user device. In particular, once a user has uploaded or created a user computational graph, the user may be able to submit a request to the system <NUM> over the data communication network <NUM> by providing input data as part of making an Application Programming Interface (API) call to the system <NUM>. In response to the API call, the system <NUM> can generate an output by executing the user computational graph and transmit the output to the user device <NUM> over the data communication network <NUM>.

The system <NUM> also maintains a collection of trained neural networks <NUM>. Each of the trained neural networks in the collection is a neural network that has been trained on training data to determine trained values of the parameters of the neural network. Generally, each of the trained neural networks is configured to perform a respective machine learning task, i.e., to receive a respective type of network input and to generate a respective type of network output.

For example, one or more of the neural networks in the collection may have been trained to classify input images, e.g., to receive an input image of a particular size, i.e., an x by y by z tensor of color values, and to generate an output vector that includes a respective score for each of multiple object categories.

As another example, one or more of the neural networks in the collection may have been trained to generate an embedding of a particular type of input, e.g., a word, a phrase, an image, or a video. An embedding is a numeric representation of the input in an embedding space, e.g., a vector of floating point values or of quantized floating point values.

As another example, one or more of the neural networks in the collection may have been trained to translate a sequence of text in a source language into a sequence of text in a target language.

For each trained neural network, the maintained data includes sufficient data for the system to process an input to the trained neural network in accordance with the trained values of the parameters of the neural network, i.e., data specifying the architecture of the trained neural network and the trained values of the parameters of the neural network. Because the system is configured to perform computations by executing computational graphs, the maintained data is generally sufficient for the system to instantiate a computational graph representing the trained neural network. For example, the maintained data can include data in a structured format, e.g., protocol buffers, that identifies, for each node of the computational graph, inputs and outputs to the node and the computation performed by the node.

The system <NUM> also includes a graph augmentation engine <NUM> that, in response to user requests, augments a user computational graph <NUM> with a pre-trained neural network <NUM>. That is, the graph augmentation engine <NUM> can modify a user computational graph to also include the operations performed by a pre-trained neural network from the collection <NUM>.

In particular, as will be described in more detail below, the graph augmentation engine <NUM> can augment the user computational graph by inserting a node to the user computational graph that, when executed, provides an input to a pre-trained neural network, obtains an output from the pre-trained neural network, and then provides the output as an output of the node in the user computational graph, i.e., to another node that is connected to the node by an edge in the user computational graph or as the output of the user computational graph.

<FIG> is a flow diagram of an example process <NUM> for augmenting a computational graph to include a trained neural network. For convenience, the process <NUM> will be described as being performed by a system of one or more computers, located in one or more locations, and programmed appropriately in accordance with this specification. For example, a computational graph system, e.g., the computational graph system <NUM> of <FIG>, appropriately programmed, can perform the process <NUM>.

The system maintains data specifying a collection of trained neural networks (step <NUM>).

As described above, each of the trained neural networks in the collection is a neural network that has been trained on training data to determine trained values of the parameters of the neural network. Generally, each of the trained neural networks is configured to perform a respective machine learning task, i.e., to receive a respective type of network input and to generate a respective type of network output.

The system obtains, from a user of the system, data representing a user computational graph of nodes and directed edges (<NUM>). For example, the user can upload computational graph data from a user device and to the system over a data communication network. As another example, the system can present a user interface to the user device through which the user can submit inputs specifying the computational graph, i.e., inputs defining the nodes and edges of the user computational graph.

The user computational graph is a computational graph to be maintained and executed by the system, i.e., to be executed by the system on devices that are managed by the system and that are generally remote from the user device of the user. A "remote" device means one having a processor external to a first device (e.g. the user device), e.g. within a separate exterior housing from an exterior housing of the first device. Typically, a remote device communicates with the first device over a communications network and/or it includes a processor operating based on a clock signal which is not used in the first device.

For example, when the user computational graph is a computational graph that represents neural network inference operations, i.e., operations for processing one or more network inputs through a neural network to generate a respective network output for each of the network inputs, the user may provide network inputs to the system for processing by the neural network. The system can then perform the operations specified by the user computational graph on each network input to generate a network output and then provide the network outputs to the user.

As another example, when the user computational graph is a computational graph that represents neural network training operations, i.e., operations for training a neural network on training data, the user can provide training data to the system over the network and the system can train the neural network on the training data by executing the computational graph. Once the neural network has been trained, the system can provide data specifying the trained parameter values of the neural network to the user or can execute an inference graph for the trained neural network to generate network outputs for network inputs provided by the user.

The system determines that the user computational graph needs to be augmented with one of the trained neural networks in the collection of trained neural networks (<NUM>).

In the present invention, the system makes this determination based at least in part on user input. The user submits an input to the system that specifies an insertion point in the user computational graph, i.e., a source node in the user computational graph that generates the output that should be provided as input to the trained neural network and a destination for the output of the trained neural network, i.e., another node in the user computational graph or an output of the user computational graph. In non-claimed examples, the system can then present a user interface that allows the user to select a neural network from the trained neural networks in the collection to be added to the user computational graph at the insertion point. In the present invention, the system analyzes the collection of trained neural networks to identify any neural networks in the collection that conform to the insertion point. A neural network conforms to the insertion point if it takes inputs that have the same dimensions and size as the output tensor generated by the source node in the user computational graph and that generate outputs that have the same dimensions and size that are required by the destination in the user computational graph.

In some implementations, the system can analyze the user computational graph and identify a portion, i.e., a sub-graph of one or more nodes, of the user computational graph that should be replaced by one of the neural networks in the collection of trained neural networks. For example, the system can analyze the user computational graph for sub-graphs that generate outputs and receive inputs that conform to the outputs and inputs of a trained neural network in the computational graph. In these implementations, the insertion point would be a connection between the input edge to the identified sub-graph and the output edge of the identified sub-graph. The system can then prompt the user to replace the identified sub-graph of the user computational graph with the trained neural network.

The system augments the user computational graph with the trained neural network (<NUM>).

Generally, the system augments the user computational graph with the trained neural network such that, when the system executes the user computational graph (e.g. by inputting data into the user computational graph; the data input to the user computational graph is referred to as a "graph input"), the operations of the trained neural network are performed at the appropriate points during execution, but the architecture and trained parameter values of the trained neural network are not transparent to the user. That is, the system may not transmit or make accessible to the user sufficient data to determine the architecture and/or trained parameter values. Indeed, preferably the system does not output sufficient such data at all, e.g. not to a user viewing a representation of the user computational graph in a user interface.

In particular, the system includes a reference to the trained neural network at the insertion point in the user computational graph. At runtime of the user computational graph, the system resolves the reference to bind the user computational graph to an input node to the graph representing the trained neural network, i.e., so that the tensor generated as output by the particular node in the user computational graph is provided as input to the input node in the graph representing the trained neural network and the output tensor generated by the output node in the graph representing the trained neural network is provided as input to the appropriate node in the user computational graph or, in some cases, as the output of the user computational graph.

In the present invention, the included reference is a remote call node inserted into the user computational graph at the insertion point. A remote call node in a computational graph is a node that, when the computational graph is executed, receives an input flowing along the incoming edge to the remote call node and issues a remote call with the input. As used in this specification, a remote call is a request that triggers the system to execute a computational graph that (i) is identified by the remote call, (ii) is different from the graph in which the remote call node is included, and (iii) that takes as input a tensor included with the remote call and to return in response to the request the result of executing the computational graph, i.e., the output of one or more particular output nodes in the identified computational graph. The remote call node then waits until an output is received from the remote graph in response to the remote call and provides the received output along the outgoing edge(s) of the remote call node. In particular, the remote graph is the computational graph representing the trained neural network. Thus, because the remote call node calls a remote graph and receives an output from the remote graph, the node structure and operations performed by the remote graph are not available when accessing, i.e., viewing, the user computational graph in which the remote call node is included or when submitting inputs to be processed by the user computational graph. In some implementations, the remote call node identifies the trained neural network by pointing to a graph identifier of the graph representing the trained neural network and a production environment for executing the identified graph.

In some implementations, the system maintains a single instance of the computational graph representing the trained neural network and resolves requests from multiple user computational graphs to the same instance. In other implementations, the system resolves requests from each user computational graph to a different instance of the computational graph representing the trained neural network.

The system receives a request to execute the user computational graph (step <NUM>). For example, the system can receive a network input and a request to generate a network output for the network input.

The system executes the user computational graph augmented with the trained neural network (step <NUM>).

That is, the system executes the user computational graph and, because the user computational graph includes the reference to the trained neural network, the execution causes an input tensor to the included reference, e.g., to the remote call node, to be passed to the trained neural network and the output generated by the trained neural network to be passed as input to the appropriate portion of the user computational graph.

In particular, when the system receives the call identifying the trained neural network, the system can, remotely from the execution of the user computational graph, execute a computational graph representing the trained neural network (the "remote graph") on the input tensor to generate an output tensor, and then provide the output tensor in response to the remote call.

Generally, when the user computational graph is a computational graph for training neural network (a "training graph"), the system would adjust the values of the parameters of the neural network during the training procedure, i.e., during execution of the training graph. In particular, training graphs generally include a forward path for computing an output in accordance with current values of the parameters of the neural network based on a received input and a backward path for updating the current parameter values based on a loss between the generated output and a known output for the generated input. When the user computational graph is a training graph, the system can insert call nodes at appropriate points in both the forward and backward paths of the user training graph.

In some implementations, the system holds the parameters of the trained neural network fixed during execution of the training graph.

In other implementations, the system can also adjust the values of the parameters of the trained neural network. For example, the system can train the trained neural network for "fine-tuning", with a reduced learning rate from the rest of the user computational graph. As another example, the system can train the trained neural network with the same learning rate. The system can train the trained neural network by passing gradient values as a remote call as input to a backward/training path through the remote graph and providing gradient values from the remote graph as input to the appropriate location in the backward path through the user computational graph. In these cases, by fine-tuning the already-trained neural network, the system allows the performance of the trained neural network to be customized for the training data and task specified by the user while still leveraging the already high-quality performance afforded by the pre-training. Additionally, the performance of the user computational graph is improved without either the original or fine-tuned parameter values of the trained neural network being transparent to the user.

<FIG> illustrates an example computational graph <NUM> that has been augmented with a remote call node <NUM>. In addition to the remote call node <NUM>, the computational graph also includes nodes, <NUM>, <NUM>, <NUM>, <NUM>, and <NUM>. As a simplified example, a computational graph system, e.g., the system <NUM> of <FIG>, can receive a request from a user to, given a set of inputs, compute an inference using the computational graph. In particular, the client can request an output of node <NUM> of the graph <NUM>. The set of inputs can be provided on a directed edge to the node <NUM> of the graph <NUM>.

During execution of the graph <NUM>, the remote call node receives an input tensor <NUM> generated as output of the node <NUM> and provides an output tensor <NUM> as input to the node <NUM>. In particular, upon receiving the input tensor <NUM>, the remote call node <NUM> issues a remote call to a graph representing a trained neural network <NUM>. In the example of <FIG>, the trained neural network <NUM> is a convolutional neural network that receives the input tensor <NUM> and generates the output tensor <NUM>, e.g., a classification or an embedding of the input tensor <NUM>.

Upon receiving the output tensor <NUM> from the trained neural network <NUM>, the remote call node <NUM> provides the output tensor <NUM> as input to the node <NUM>. Because the call is remote, i.e., not local to the user computation graph, the architecture and the trained parameter values do not become known to the owner of the user computational graph.

Claim 1:
A computer-implemented method comprising:
maintaining (<NUM>), by a computational graph system (<NUM>) that manages execution of computational graphs (<NUM>) representing neural network operations for users of the computational graph system, data specifying a plurality of pre-trained neural networks (<NUM>), wherein each of the pre-trained neural networks is a neural network that has been trained on training data to determine trained values of the respective parameters of the neural network;
receiving (<NUM>) from a user, via a user interface presented to a user, input data specifying a user computational graph (<NUM>) representing neural network operations, the user computational graph comprising a plurality of nodes (<NUM>-<NUM>) connected by edges;
receiving from the user a user input specifying an insertion point after a first node (<NUM>) in the user computational graph;
identifying a particular computational graph for a particular pre-trained neural network (<NUM>) from the plurality of pre-trained neural networks, the identifying comprising analyzing the pre-trained neural networks (<NUM>) in the plurality of pre-trained neural networks to identify a neural network (<NUM>) that takes inputs that have the same dimensions and size as an output tensor generated by the first node and that generates outputs that have the same dimensions and size that are required by a destination in the user computational graph; and
inserting (<NUM>) a remote call node (<NUM>) into the user computational graph, wherein the remote call node is a node of the user computational graph which is configured to, during execution of the user computational graph:
receive an output tensor (<NUM>) generated by the first node of the user computational graph,
provide, using a remote call (<NUM>), the output tensor as input to the particular computational graph for the particular trained neural network,
obtain, in response to the remote call, a network output (<NUM>) generated by executing the particular computational graph for the particular trained neural network (<NUM>), and
provide the network output generated by the particular trained neural network as an output of the remote call node;
receiving a graph input to the user computational graph; and
executing (<NUM>) the user computational graph with the inserted remote call node on the graph input.