Module drug::nodes

source ·
Expand description

This module holds the different types nodes that exist in a computation graph. Nodes that represent a differentiable computation are implemented by a struct with the “Operation” trait. Use Graph methods to create and register nodes inside a graph. See Node for the types of node available. This module may eventually be made private…

Structs

Elementwise addition operation
Implements convolution Operation that supports striding and padding. It takes two arguments, kernel, and input. The output shape depends on striding, padding, and eventually dialation (not yet implemented).
Trainable embedding operation, given an index and a 2d-array of embedding vectors, index into the embedding vectors. FIXME drug hardcodes ArrayD<f32> inside the graph so the index should be a batch_size length arrayD<f32> where the values are integers.
implements matrix multiply Operation. See Node constructor for full description.
Elementwise multiplication operation

Enums

Elementwise Activation, which could be leaky relu, sigmoid or tanh
Type of pooling operation (currently there is only average pooling). TODO enum max pool, avg pool, sum pool, min pool Implements Operation. See Node constructor for full description.
Nodes are the building blocks of the computation graph. The variants of a node differ in how the value is produced and how loss is propagated back. Users typically interact with Nodes with their index :Idx which is returned by the graph when registered / created.
Type of padding to use in a Conv node . No padding means a non-strided convolution will shrink by the dimensions of the kernel as pixels at the edge will not be the center of a convolution. Same padding allows for convolution of edge pixels by assuming the values beyond the images are equal to the edge. Other not implemented padding strategies are “Zero” padding or “Reflection” padding.

Traits

Represents a differentiable function in a computation graph. Operations hold their own hyperparameters but not their parameters, values or losses. Unfortunately boxed traits cannot be saved with serde. When reloaded they will be replaced by Box<arithmetic::Add> nodes. When reloading a model with custom Operations, you need to replace them manually.