models

This module contains classes to implement Keras-style Models, which combine several NetworkLayers to simulate a full optical neural network. Currently, only sequential models are supported, but more may be added in the future.

class neuroptica.models.BaseModel[source]

Bases: object

Base class for all models

__weakref__

list of weak references to the object (if defined)

class neuroptica.models.Model[source]

Bases: neuroptica.models.BaseModel

Functional model class similar to the Keras model class, simulating an optical neural network with multiple layers

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

class neuroptica.models.Sequential(layers: List[neuroptica.layers.NetworkLayer])[source]

Bases: neuroptica.models.BaseModel

Feed-foward model class similar to the Keras Sequential() model class

__init__(layers: List[neuroptica.layers.NetworkLayer])[source]

Initialize the model :param layers: list of NetworkLayers contained in the optical neural network

__repr__()[source]

Return repr(self).

backward_pass(d_loss: <MagicMock id='140414709717760'>, cache_fields=False, use_partial_vectors=False) → Dict[str, <MagicMock id='140414709734312'>][source]

Returns the gradients for each layer resulting from backpropagating from derivative loss function d_loss :param d_loss: derivative of the loss function of the outputs :param cache_fields: if true, fields will be cached internally :param use_partial_vectors: if true, use the partial vectors method to speed up transfer matrix computation :return: dictionary of {layer: gradients}

forward_pass(X: <MagicMock id='140414709688864'>, cache_fields=False, use_partial_vectors=False) → <MagicMock id='140414709705304'>[source]

Propagate an input field throughout the entire network :param X: input electric fields :param cache_fields: if true, fields will be cached internally :param use_partial_vectors: if true, use the partial vectors method to speed up transfer matrix computation :return: output electric fields (to be fed into a loss function)