deepxde.nn.tensorflow
deepxde.nn.tensorflow.deeponet module
- class deepxde.nn.tensorflow.deeponet.DeepONet(*args, **kwargs)[source]
Bases:
NN
Deep operator network.
- Parameters:
layer_sizes_branch – A list of integers as the width of a fully connected network, or (dim, f) where dim is the input dimension and f is a network function. The width of the last layer in the branch and trunk net should be the same for all strategies except “split_branch” and “split_trunk”.
layer_sizes_trunk (list) – A list of integers as the width of a fully connected network.
activation – If activation is a
string
, then the same activation is used in both trunk and branch nets. If activation is adict
, then the trunk net uses the activation activation[“trunk”], and the branch net uses activation[“branch”].num_outputs (integer) – Number of outputs. In case of multiple outputs, i.e., num_outputs > 1, multi_output_strategy below should be set.
multi_output_strategy (str or None) –
None
, “independent”, “split_both”, “split_branch” or “split_trunk”. It makes sense to set in case of multiple outputs.None
Classical implementation of DeepONet with a single output. Cannot be used with num_outputs > 1.
independent
Use num_outputs independent DeepONets, and each DeepONet outputs only one function.
split_both
Split the outputs of both the branch net and the trunk net into num_outputs groups, and then the kth group outputs the kth solution.
split_branch
Split the branch net and share the trunk net. The width of the last layer in the branch net should be equal to the one in the trunk net multiplied by the number of outputs.
split_trunk
Split the trunk net and share the branch net. The width of the last layer in the trunk net should be equal to the one in the branch net multiplied by the number of outputs.
- call(inputs, training=False)[source]
Calls the model on new inputs and returns the outputs as tensors.
In this case call() just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__() method, i.e. model(inputs), which relies on the underlying call() method.
- Parameters:
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a boolean tensor or None (no mask). For more details, check the guide [here](https://www.tensorflow.org/guide/keras/masking_and_padding).
- Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class deepxde.nn.tensorflow.deeponet.DeepONetCartesianProd(*args, **kwargs)[source]
Bases:
NN
Deep operator network for dataset in the format of Cartesian product.
- Parameters:
layer_sizes_branch – A list of integers as the width of a fully connected network, or (dim, f) where dim is the input dimension and f is a network function. The width of the last layer in the branch and trunk net should be the same for all strategies except “split_branch” and “split_trunk”.
layer_sizes_trunk (list) – A list of integers as the width of a fully connected network.
activation – If activation is a
string
, then the same activation is used in both trunk and branch nets. If activation is adict
, then the trunk net uses the activation activation[“trunk”], and the branch net uses activation[“branch”].num_outputs (integer) – Number of outputs. In case of multiple outputs, i.e., num_outputs > 1, multi_output_strategy below should be set.
multi_output_strategy (str or None) –
None
, “independent”, “split_both”, “split_branch” or “split_trunk”. It makes sense to set in case of multiple outputs.None
Classical implementation of DeepONet with a single output. Cannot be used with num_outputs > 1.
independent
Use num_outputs independent DeepONets, and each DeepONet outputs only one function.
split_both
Split the outputs of both the branch net and the trunk net into num_outputs groups, and then the kth group outputs the kth solution.
split_branch
Split the branch net and share the trunk net. The width of the last layer in the branch net should be equal to the one in the trunk net multiplied by the number of outputs.
split_trunk
Split the trunk net and share the branch net. The width of the last layer in the trunk net should be equal to the one in the branch net multiplied by the number of outputs.
- call(inputs, training=False)[source]
Calls the model on new inputs and returns the outputs as tensors.
In this case call() just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__() method, i.e. model(inputs), which relies on the underlying call() method.
- Parameters:
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a boolean tensor or None (no mask). For more details, check the guide [here](https://www.tensorflow.org/guide/keras/masking_and_padding).
- Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class deepxde.nn.tensorflow.deeponet.PODDeepONet(*args, **kwargs)[source]
Bases:
NN
Deep operator network with proper orthogonal decomposition (POD) for dataset in the format of Cartesian product.
- Parameters:
pod_basis – POD basis used in the trunk net.
layer_sizes_branch – A list of integers as the width of a fully connected network, or (dim, f) where dim is the input dimension and f is a network function. The width of the last layer in the branch and trunk net should be equal.
activation – If activation is a
string
, then the same activation is used in both trunk and branch nets. If activation is adict
, then the trunk net uses the activation activation[“trunk”], and the branch net uses activation[“branch”].layer_sizes_trunk (list) – A list of integers as the width of a fully connected network. If
None
, then only use POD basis as the trunk net.
References
- call(inputs, training=False)[source]
Calls the model on new inputs and returns the outputs as tensors.
In this case call() just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__() method, i.e. model(inputs), which relies on the underlying call() method.
- Parameters:
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a boolean tensor or None (no mask). For more details, check the guide [here](https://www.tensorflow.org/guide/keras/masking_and_padding).
- Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
deepxde.nn.tensorflow.fnn module
- class deepxde.nn.tensorflow.fnn.FNN(*args, **kwargs)[source]
Bases:
NN
Fully-connected neural network.
- call(inputs, training=False)[source]
Calls the model on new inputs and returns the outputs as tensors.
In this case call() just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__() method, i.e. model(inputs), which relies on the underlying call() method.
- Parameters:
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a boolean tensor or None (no mask). For more details, check the guide [here](https://www.tensorflow.org/guide/keras/masking_and_padding).
- Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class deepxde.nn.tensorflow.fnn.PFNN(*args, **kwargs)[source]
Bases:
NN
Parallel fully-connected neural network that uses independent sub-networks for each network output.
- Parameters:
layer_sizes – A nested list to define the architecture of the neural network (how the layers are connected). If layer_sizes[i] is int, it represent one layer shared by all the outputs; if layer_sizes[i] is list, it represent len(layer_sizes[i]) sub-layers, each of which exclusively used by one output. Note that len(layer_sizes[i]) should equal to the number of outputs. Every number specify the number of neurons of that layer.
- call(inputs, training=False)[source]
Calls the model on new inputs and returns the outputs as tensors.
In this case call() just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__() method, i.e. model(inputs), which relies on the underlying call() method.
- Parameters:
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a boolean tensor or None (no mask). For more details, check the guide [here](https://www.tensorflow.org/guide/keras/masking_and_padding).
- Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
deepxde.nn.tensorflow.nn module
- class deepxde.nn.tensorflow.nn.NN(*args, **kwargs)[source]
Bases:
Model
Base class for all neural network modules.
- apply_feature_transform(transform)[source]
Compute the features by appling a transform to the network inputs, i.e., features = transform(inputs). Then, outputs = network(features).
- apply_output_transform(transform)[source]
Apply a transform to the network outputs, i.e., outputs = transform(inputs, outputs).
- property auxiliary_vars
Any additional variables needed.
- Type:
Tensors