BCN reference

Models

BCN

class bcn.BCN(width, depth, *, connections=<Connections.ONE_TO_9: 9>, branches=None, device=None, mean=0.0, std=0.05, dropout=0.0, activation=<built-in method sigmoid of type object>, verbose=0, **kwargs)

Represents a branched connection network.

Parameters
  • width (int) – The side length of each layer.

  • depth (int) – The depth of the network, equal to the number of nonlinear activations.

Keyword Arguments
  • connections – The number of direct connections each neuron makes. Default is 1-to-9.

  • branches – The type of indirect (branching) connections used to construct the branching networks for each layer. Default is direct connections only.

  • device – The torch.device object on which the tensors will be allocated. Default is GPU if available, otherwise CPU.

  • mean – The mean of the normal distribution to initialize weights, default 0.0.

  • std – The standard deviation of the normal distribution to initialize weights, default 0.05.

  • dropout – The dropout factor to use for each layer; default 0.0. If provided a tuple of floats, use the values for the corresponding layer. For example, (0, 0.3, 0.5) will set the dropout of the third layer (and following layers if there are any) to 0.5, whereas the first and second layers will have dropouts of 0 and 0.3 respectively.

  • activation – The activation function to use between layers. Default is sigmoid.

  • verbose – Verbosity level. 0 (default) is no text, 1 is some, 2 is most verbose. Might become deprecated in future versions.

width

The side length of each layer.

Type

int

hw

The product of each layer’s height and width, namely width * width in this version of BCN.

Type

int

depth

The depth of the network, equal to the number of nonlinear activations.

Type

int

connections

The number of direct connections each neuron makes.

Type

Connections

branches

The type of indirect (branching) connections used to construct the branching networks for each layer. Default is direct connections only.

Type

Branches

device

The torch.device object on which the tensors will be allocated.

Type

torch.device

mean

The mean of the normal distribution used to initialize weights.

Type

float

std

The standard deviation of the normal distribution used to initialize weights.

Type

float

dropout

The proportion of dropout to use for each layer, as a tuple of floats corresponding to the first layer, second, and so on. If the length of this tuple is less than the number of layers, then the reamining layers use the last value in the tuple.

Type

Tuple[float,..]

activation

The activation function used between layers.

verbose

Verbosity level. 0 (default) is no text, 1 is some, 2 is most verbose. Might become deprecated in future versions.

Type

int

trial

The trial of this model experiment, specified by the BCN.train method. Used when naming the weights & results files. If None, this model does not represent any particular trial.

Type

Optional[int]

scheme

The training scheme to use when training this model. Specified by the BCN.train method.

Type

Optional[TrainingScheme]

save_path

The path to save weights & results so, specified with the BCN.train method.

Type

Optional[Path]

results

The model training results.

Type

Results

layers

The list of BCNLayer layers.

Type

ModuleList

clone(clone_results=True)

Return a duplicate of this model with weight tensors separate in memory.

Parameters

clone_results (bool) – Whether to clone the Results too, default True.

Returns

Duplicate of this model.

Return type

BCN

confusion(*, valid=True, fault=None, shuffle=False, limit=60000)

Construct an interclass confusion matrix for this model.

Important

Remember to set the training scheme before running this method.

Keyword Arguments
  • valid – Whether to use the validation set (True, default) or the training set (False).

  • fault – The set of fault masks to use, if any.

  • shuffle – Whether to shuffle the dataset when evaluating (True), or not (False, default).

  • limit – The maximum size of the dataset to evaluate on. Default is 60000.

Returns

Confusion matrix of integers.

Return type

torch.Tensor

static construct_network(width, connections, branches, device=None)

Construct the connection matrices that determine how to pass one layer to the next.

See thesis Chapter 3 for more details about how this works.

Parameters
  • width (int) – The width of each BCN plane, e.g. 28.

  • connections (Connections) – The number of direct connections, e.g. ONE_TO_9.

  • branches (Branches) – The type of branching connections, e.g. NearestNeighbor.

  • device (Optional[device]) – The device that the torch tensors should live within. Default is to choose GPU if available, otherwise CPU.

Returns

The 3D tensor of connections that coordinates the layer-to-layer transformation.

Return type

torch.Tensor

property default_results_filename

The way this model’s results file will be named by default.

Example

results_30x30x3@9-DirectOnly.MNIST.b64.t2.pkl

Note

Remember to set this model’s trial using BCN.train before accessing this property.

Return type

str

property default_weights_filename

The way this model’s weights file will be named by default.

Example

weights_30x30x3@9-NearestNeighborOnly.MNIST.b64.t2.pt

Note

Remember to set this model’s trial using BCN.train before accessing this property.

Return type

str

evaluate(*, valid=True, fault=None, shuffle=False, use_tqdm=True, limit=60000)

Evaluate this model.

Important

Remember to set the training scheme before running this method.

Keyword Arguments
  • valid – Whether to use the validation set (True, default) or the training set (False).

  • fault – The set of fault masks to use, if any.

  • shuffle – Whether to shuffle the dataset when evaluating (True), or not (False, default).

  • use_tqdm – Whether to use tqdm (True, default) or not (False).

  • limit – The maximum size of the dataset to evaluate on. Default is 60000.

Returns

Loss, accuracy, precision, recall, and F1 score.

Return type

Tuple[float,float,float,float,float]

forward(x, *, fault=None)

The forward computation performed at every BCN call.

Note

Call the BCN instance itself instead of using this method directly.

Parameters

x (Tensor) – The input tensor of size (features, batch_size).

Keyword Arguments

fault – The set of fault masks to use, if any.

Return type

Tensor

Returns

The output tensor of size (10, batch_size).

run_epoch(fault=None)

Train for one epoch.

Important

Remember to set the training scheme before running this method.

Return type

None

run_epochs(n, webhook=None, fault=None)

Train for some number of epochs.

Parameters
  • n (int) – The number of epochs to train for.

  • webhook (Optional[str]) – The Discord or Slack webhook URL to post to. See here for what it looks like.

Return type

None

run_wp(n, approach=<WPApproach.RASTER: 0>, epsilon=0.01, fault=None, webhook=None)

Run some rounds of weight perturbation.

Parameters
  • n (int) – The number of weight perturbation steps to perform.

  • approach (WPApproach) – The approach to weight perturbation. Default is WPApproach.RASTER.

  • epsilon (float) – Multiplicative learning rate. Default is 0.01, AKA 1%.

  • fault (Optional[Fault]) – The set of fault masks to use, if any.

  • webhook (Optional[str]) – The Discord or Slack webhook URL to post to.

train(flag=True, *, scheme=None, from_weights=None, from_results=None, from_path=None, save_path=None, trial=None, tag='')

Set the model to training mode and update the training scheme.

Sets the training scheme for this model, and switches the model to training mode. Loads weights if given. Also specifies some model attributes related to training, as given.

Parameters

scheme (Optional[TrainingScheme]) – The training scheme that this model should follow.

Keyword Arguments
  • from_weights – Weights file to begin training from; default is to initialize weights randomly.

  • from_results – Results file to load; default is not to load any results.

  • from_path – The directory that the model should look under to load the weights and results, using the BCN.default_weights_filename and BCN.default_results_filename filenames. In practice, this is usually identical to the save_path parameter. If either of the explicit parameters from_weights or from_results are also specified, the model will use those.

  • trial – Assign the model a trial number, for the sake of repeating experiments. Default is None, in which case the model isn’t assigned a trial number.

  • save_path – Path to save weights to.

  • tag – Anything notable about the model or results. Intended to be used as plot titles when plotting.

Return type

None

BCNLayer

class bcn.BCNLayer(width, *, connections=<Connections.ONE_TO_9: 9>, branches=None, device=None, dropout=0.0, mean=0.0, std=0.05, activation=<built-in method sigmoid of type object>, last=False)

Represents a branched connection network layer.

Parameters

width (int) – The side length of the layer.

Keyword Arguments
  • connections – The number of direct connections each neuron makes. Default is 1-to-9.

  • branches – The type of indirect (branching) connections used to construct the branching network. Default is direct connections only.

  • device – The torch.device object on which the tensors will be allocated. Default is GPU if available, otherwise CPU.

  • dropout – The proportion of dropout to use for this layer, default 0.0.

  • mean – The mean of the normal distribution to initialize weights, default 0.0.

  • std – The standard deviation of the normal distribution to initialize weights, default 0.05.

  • activation – The activation function to use between layers. Default is sigmoid.

  • last – Whether the layer is the final layer in the model or not, default False. If True, the forward output is a (10, -1) tensor representing the raw, unnormalized scores of the ten-digit “keypad” (refer to thesis, Figure 3-3 and associated text) ready for cross entropy loss.

width

The side length of the layer.

Type

int

hw

The product of the layer’s height and width, namely width * width in this version of BCN.

Type

int

connections

The number of direct connections each neuron makes.

Type

Connections

branches

The type of indirect (branching) connections used to construct the branching network.

Type

Branches

device

The torch.device object on which the tensors will be allocated. Default is GPU if available, otherwise CPU.

Type

torch.device

dropout

The torch Dropout module use when training.

Type

torch.nn.Dropout

mean

The mean of the normal distribution used to initialize weights.

Type

float

std

The standard deviation of the normal distribution used to initialize weights.

Type

float

activation

The activation function used between layers.

last

Whether the layer is the final layer in the model or not. If True, the forward output is a (10, -1) tensor representing the raw, unnormalized scores of the ten-digit “keypad” (refer to thesis, Figure 3-3 and associated text) ready for cross entropy loss.

Type

bool

ells

A range of offsets, centered around 0, used for the direct connections. For example, 1-to-25 connections will range from -2 to +2 inclusive, because this represents a span of width 5.

Type

range

network

In future versions, this will probably be a tensor for performance reasons. I’ll hold off on complete documentation for now.

Type

Dict[Tuple[int,int],torch.Tensor]

weights

In future versions, this will probably be a tensor for performance reasons. I’ll hold off on complete documentation for now.

Type

Dict[Tuple[int,int],torch.nn.Parameter]

mask

If this is a last layer, the mask attribute represents a tensor that filters the output to ten values. None if this is not a last layer.

Type

Optional[torch.Tensor]

property default_network_filename

The way this model’s network file will be named by default.

Example

30x30@9-uniform.NearestNeighbor.pt

Return type

str

forward(x)

The forward computation performed at every BCNLayer call.

Note

Call the BCNLayer instance itself instead of using this method directly.

Parameters

x (Tensor) – The input tensor of size (features, batch_size).

Return type

Tensor

Returns

The output tensor. Size is (features, batch_size) if this layer is not the last layer, otherwise (10, batch_size).

Connections

class bcn.Connections(value)

Enum class representing the number of directed connections AKA “arms”.

ONE_TO_1

Represents a connection scheme in which each neuron in the input plane directly connects only to the nearest neuron in the next layer.

ONE_TO_9

Represents a connection scheme in which each neuron in the input plane connects to at most the nine nearest neighbors in the output plane.

ONE_TO_25

Represents a connection scheme in which each neuron in the input plane connects to at most the 25 nearest neighbors in the output plane.

ONE_TO_49

Represents a connection scheme in which each neuron in the input plane connects to at most the 49 nearest neighbors in the output plane.

ONE_TO_81

Represents a connection scheme in which each neuron in the input plane connects to at most the 81 nearest neighbors in the output plane.

FULLY_CONNECTED

Represents a connection scheme in which each neuron in the input plane connects to all neurons in the output plane.

Warning

Use with caution.

One of the tradeoffs I’ve made with how I’ve designed the BCN connections is intuitiveness & convenience for file sizes. Specifically, the more connected a model, the larger the connections take up in memory.

More specifically, if a 30x30 1-to-9 connection scheme is 29 MB, then a 30x30 1-to-81 connection scheme would be 261 MB, and a fully connected 30x30 network would be … 2.9 GB???

Branches

Base class

class bcn.branches.Branches(width=9)

Base class representing branching connections.

Each branching (indirect) connection is encoded by a matrix where each element represents the connection from a previous layer to the following layer. The center of this matrix represents the connection from a previous layer’s neuron to the single nearest neighbor neuron in the next layer. Likewise, off center elements represent connections from a previous layer’s neuron to off center nearest neighbor neurons. Class instances act the same as Python dicts.

Note

Directly index into this class’s instances instead of using the Branches.connections dict.

Parameters

width (int) – Size of the matrices representing the branches. Default 9.

width

Size of the matrices representing the branches.

Type

int

center

index of the center of the matrices representing the branches.

Type

int

connections

Map from 2-dimensional offset to the matrix that represents the indirect connections/convolution kernel.

Type

Dict[Tuple[int,int],torch.Tensor]

default

The matrix to use when an offset isn’t defined in Branches.connections.

Type

torch.Tensor

name

Formal name of the set of branches.

Type

str

latex

A string of LaTeX representing the center connection as a matrix.

Type

str

normalize(norm=1)

Normalize the sum of the connections to a norm.

Parameters

norm (float) – The norm to use, default 1.

Return type

None

static pan(x, dy, dx)

Pan a tensor x down dy and over dx.

Similar to torch.roll, circularly convolves the given tensor, instead with zero padding.

Parameters
  • x (Tensor) – 2D matrix to pan.

  • dy (int) – Count of places to shift the tensor downward.

  • dx (int) – Count of places to shift the tensor rightward.

Returns

Panned/shifted matrix.

Return type

torch.Tensor

Direct connections only

class bcn.branches.DirectOnly(*args, **kwargs)

Branches class representing only direct connections (“pristine”, “ideal”).

For direct-only connections, each arm has only one finger. This is more or less equivalent to a standard dense neural network layer.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & 1.00 & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]

Empirically based branches

class bcn.branches.Vital

Connection matrices designed by Inoela Vital and Cardinal Warde ca. 2021.

Based off of the empirical numbers obtained by William “Bill” Herrington ca. 2015.

Note

This is used with 1-to-9 connections or 1-to-25 connections only.

Uniform branches

These branches have equal non-zero values.

class bcn.branches.uniform.NearestNeighbor(*args, **kwargs)

Branches class representing nearest neighbor connections.

For nearest neighbor connections, each arm has 9 fingers.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & 0.11 & 0.11 & 0.11 & \> & \> & \>\\ \> & \> & \> & 0.11 & 0.11 & 0.11 & \> & \> & \>\\ \> & \> & \> & 0.11 & 0.11 & 0.11 & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.uniform.NextToNN(*args, **kwargs)

Branches class representing next-to-nearest neighbor connections.

For next-to-nearest neighbor connections, each arm has 25 fingers.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.uniform.NearestNeighborOnly(*args, **kwargs)

Branches class representing nearest neighbor connections without the center connection.

For this connection scheme, each arm has 8 fingers touching the corresponding first ring of indirect target neurons.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & 0.12 & 0.12 & 0.12 & \> & \> & \>\\ \> & \> & \> & 0.12 & \> & 0.12 & \> & \> & \>\\ \> & \> & \> & 0.12 & 0.12 & 0.12 & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.uniform.NextToNNOnly(*args, **kwargs)

Branches class representing next-to-nearest neighbor connections without the innermost rings.

For this connection scheme, each arm has 16 fingers touching the corresponding second ring of indirect target neurons.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.06 & 0.06 & 0.06 & 0.06 & 0.06 & \> & \>\\ \> & \> & 0.06 & \> & \> & \> & 0.06 & \> & \>\\ \> & \> & 0.06 & \> & \> & \> & 0.06 & \> & \>\\ \> & \> & 0.06 & \> & \> & \> & 0.06 & \> & \>\\ \> & \> & 0.06 & 0.06 & 0.06 & 0.06 & 0.06 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.uniform.IndirectOnly(*args, **kwargs)

Nearest and next-to-nearest neighbor Branches class, without the center connection.

For this connection scheme, each arm has 24 fingers, touching the corresponding first two rings of indirect target neurons.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & \> & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & 0.04 & 0.04 & 0.04 & 0.04 & 0.04 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]

“Simple” branches

These branches have equal power in the center, first ring, and second ring, where applicable.

class bcn.branches.simple.NearestNeighbor(*args, **kwargs)

Branches class representing nearest neighbor connections.

For nearest neighbor connections, each arm has 9 fingers.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & 0.06 & 0.06 & 0.06 & \> & \> & \>\\ \> & \> & \> & 0.06 & 0.50 & 0.06 & \> & \> & \>\\ \> & \> & \> & 0.06 & 0.06 & 0.06 & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.simple.NextToNN(*args, **kwargs)

Branches class representing next-to-nearest neighbor connections.

For next-to-nearest neighbor connections, each arm has 25 fingers.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.02 & 0.02 & 0.02 & 0.02 & 0.02 & \> & \>\\ \> & \> & 0.02 & 0.04 & 0.04 & 0.04 & 0.02 & \> & \>\\ \> & \> & 0.02 & 0.04 & 0.33 & 0.04 & 0.02 & \> & \>\\ \> & \> & 0.02 & 0.04 & 0.04 & 0.04 & 0.02 & \> & \>\\ \> & \> & 0.02 & 0.02 & 0.02 & 0.02 & 0.02 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.simple.NearestNeighborOnly(*args, **kwargs)

Branches class representing nearest neighbor connections without the center connection.

For this connection scheme, each arm has 8 fingers touching the corresponding first ring of indirect target neurons.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & 0.12 & 0.12 & 0.12 & \> & \> & \>\\ \> & \> & \> & 0.12 & \> & 0.12 & \> & \> & \>\\ \> & \> & \> & 0.12 & 0.12 & 0.12 & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.simple.NextToNNOnly(*args, **kwargs)

Branches class representing next-to-nearest neighbor connections without the innermost rings.

For this connection scheme, each arm has 16 fingers touching the corresponding second ring of indirect target neurons.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.06 & 0.06 & 0.06 & 0.06 & 0.06 & \> & \>\\ \> & \> & 0.06 & \> & \> & \> & 0.06 & \> & \>\\ \> & \> & 0.06 & \> & \> & \> & 0.06 & \> & \>\\ \> & \> & 0.06 & \> & \> & \> & 0.06 & \> & \>\\ \> & \> & 0.06 & 0.06 & 0.06 & 0.06 & 0.06 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.simple.IndirectOnly(*args, **kwargs)

Nearest and next-to-nearest neighbor Branches class, without the center connection.

For this connection scheme, each arm has 24 fingers, touching the corresponding first two rings of indirect target neurons.

The center connection has the following profile.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.03 & 0.03 & 0.03 & 0.03 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.06 & 0.06 & 0.06 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.06 & \> & 0.06 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.06 & 0.06 & 0.06 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.03 & 0.03 & 0.03 & 0.03 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]

Optics-informed branches

class bcn.branches.informed.Kappa(kappa)

Grating strength

Kappa(0.0) is ordinary DirectOnly branches.

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & 1.00 & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]

Kappa(1.0) looks like:

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & \> & \>\\ \> & \> & 0.00 & 0.05 & 0.05 & 0.05 & 0.00 & \> & \>\\ \> & \> & 0.00 & 0.05 & 0.59 & 0.05 & 0.00 & \> & \>\\ \> & \> & 0.00 & 0.05 & 0.05 & 0.05 & 0.00 & \> & \>\\ \> & \> & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]

Kappa(1.5) looks like:

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.01 & 0.01 & 0.01 & 0.01 & 0.01 & \> & \>\\ \> & \> & 0.01 & 0.08 & 0.08 & 0.08 & 0.01 & \> & \>\\ \> & \> & 0.01 & 0.08 & 0.26 & 0.08 & 0.01 & \> & \>\\ \> & \> & 0.01 & 0.08 & 0.08 & 0.08 & 0.01 & \> & \>\\ \> & \> & 0.01 & 0.01 & 0.01 & 0.01 & 0.01 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]
class bcn.branches.informed.IndirectOnly

Construct a Kappa object where the direct term is 0

\[\begin{matrix} \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & 0.03 & 0.03 & 0.03 & 0.03 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.07 & 0.07 & 0.07 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.07 & \> & 0.07 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.07 & 0.07 & 0.07 & 0.03 & \> & \>\\ \> & \> & 0.03 & 0.03 & 0.03 & 0.03 & 0.03 & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \>\\ \> & \> & \> & \> & \> & \> & \> & \> & \> \end{matrix}\]