PyTorch
Layer, model and training nodes.
18 nodes. Right-click any node in the editor to read this documentation in the app.
Torch
〰️ Activation Layer
id torch_activation_layer · Torch · Python export: yes
Element-wise activation function, chosen from a list: ReLU, Sigmoid or Tanh.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | The chosen activation. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Activation | select | relu | relu, sigmoid, tanh |
➕ Add Merge
id torch_add_merge · Torch · Python export: yes
Sum two or more branches element-wise — the residual / skip connection: output = main(x) + shortcut(x). Branch shapes must match.
Inputs
| Port | Type | Description |
|---|---|---|
branch_1 | Layer | Branch 1 to add (required). |
branch_2 | Layer | Branch 2 to add (required). |
branch_3 | Layer | Branch 3 to add (optional). |
branch_4 | Layer | Branch 4 to add (optional). |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Sum of the connected branches. |
📶 BatchNorm2D Layer
id torch_batchnorm2d_layer · Torch · Python export: yes
Batch normalisation over the channels of a [batch, channels, H, W] tensor. Channels must equal the preceding Conv2D's out_channels.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
num_features | int | Number of channels (overrides the num_features field). Overrides the Channels (= out_channels of prev Conv) field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | BatchNorm2d layer. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Channels (= out_channels of prev Conv) | int | 16 |
🔀 Concat Merge
id torch_cat_merge · Torch · Python export: yes
Concatenate two or more branches along a dimension (Inception / DenseNet style). Dim 1 is the channel axis of [B, C, H, W] tensors; other dimensions must match.
Inputs
| Port | Type | Description |
|---|---|---|
branch_1 | Layer | Branch 1 to concatenate (required). |
branch_2 | Layer | Branch 2 to concatenate (required). |
branch_3 | Layer | Branch 3 to concatenate (optional). |
branch_4 | Layer | Branch 4 to concatenate (optional). |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | The branches concatenated along dim. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Concat dim | int | 1 |
🔲 Conv2D Layer
id torch_conv2d_layer · Torch · Python export: yes
2-D convolution over [batch, channels, height, width] images. Padding 'same' keeps height and width unchanged.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
in_channels | int | Channels coming in (overrides the in_channels field). Overrides the In channels field when connected. |
out_channels | int | Channels going out (overrides the out_channels field). Overrides the Out channels field when connected. |
kernel_size | int | Square kernel side length (overrides the kernel_size field). Overrides the Kernel size field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Conv2d layer, ready to chain or feed a Sequential / Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| In channels | int | 3 | |
| Out channels | int | 16 | |
| Kernel size | int | 3 | |
| Padding | select | 0 | 0, 1, 2, 3, same |
🎲 Dropout Layer
id torch_dropout_layer · Torch · Python export: yes
Randomly zeroes a fraction p of activations during training to reduce over-fitting; does nothing at evaluation time.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
p | float | Probability of zeroing each activation (0-1) (overrides the p field). Overrides the Drop probability field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Dropout layer. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Drop probability | float | 0.5 |
📦 Export ONNX
id torch_export_onnx · Torch · Python export: yes
Export the model to an ONNX file, tracing it with a random dummy input of the given shape (batch, channels, height, width).
Inputs
| Port | Type | Description |
|---|---|---|
model | Module | Model to export. |
Outputs
| Port | Type | Description |
|---|---|---|
path | str | Path of the exported .onnx file. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Path | text | model.onnx | |
| Dummy input shape | text | 1,3,32,32 |
📏 Flatten Layer
id torch_flatten_layer · Torch · Python export: yes
Flatten everything except the batch dimension, e.g. [B, C, H, W] -> [B, CHW]. Put it between conv and linear layers.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Flatten layer. |
🕸 Graph Model
id torch_graph_model · Torch · Python export: yes
Assemble a whole network from wired-together layer nodes. Connect the FINAL layer(s) of your design; the node traces every upstream connection (chains, residual skips, concatenations) and wraps the graph as one model.
Inputs
| Port | Type | Description |
|---|---|---|
output_1 | Layer | Final layer of the network. |
output_2 | Layer | Additional output layer (optional). |
output_3 | Layer | Additional output layer (optional). |
output_4 | Layer | Additional output layer (optional). |
Outputs
| Port | Type | Description |
|---|---|---|
model | Module | The assembled model (single output tensor, or a tuple for several outputs). |
➖ Linear Layer
id torch_linear_layer · Torch · Python export: yes
Fully-connected layer: y = xW + b, mapping in_features inputs to out_features outputs.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
in_features | int | Input size (overrides the in_features field). Overrides the In features field when connected. |
out_features | int | Output size (overrides the out_features field). Overrides the Out features field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Linear layer, ready to chain or feed a Sequential / Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| In features | int | 128 | |
| Out features | int | 10 |
⬇️ MaxPool2D Layer
id torch_maxpool2d_layer · Torch · Python export: yes
2-D max pooling: keeps the largest value in each window, shrinking height and width (stride 2 halves them).
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
kernel_size | int | Pooling window side length (overrides the kernel_size field). Overrides the Kernel size field when connected. |
stride | int | Step between windows (overrides the stride field). Overrides the Stride field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | MaxPool2d layer. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Kernel size | int | 2 | |
| Stride | int | 2 |
📚 MNIST Dataset
id mnist_dataset · Torch · Python export: yes
The MNIST handwritten-digit training set as a DataLoader (batches of 32: images shaped [32, 1, 28, 28], integer labels 0-9). Downloads to ./data on first use, so it needs network access once.
Outputs
| Port | Type | Description |
|---|---|---|
dataset | DataLoader | Batches of (image tensor, label) — wire into Train Image Classifier. |
📈 ReLU Layer
id torch_relu_layer · Torch · Python export: yes
ReLU activation: max(0, x), element-wise.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | ReLU activation. |
💾 Save Model
id torch_save_model · Torch · Python export: yes
Save the model's weights (state_dict) to a .pt file and pass the model through unchanged.
Inputs
| Port | Type | Description |
|---|---|---|
model | Module | Model whose weights to save. |
Outputs
| Port | Type | Description |
|---|---|---|
model | Module | The input model, unchanged. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Path | text | model.pt |
🧱 Sequential
id torch_sequential · Torch · Python export: yes
Chain layers, in port order, into a plain nn.Sequential model. Wire layers into layer_1, layer_2, ... For branching / residual designs use Graph Model instead.
Inputs
| Port | Type | Description |
|---|---|---|
layer_1 | Layer | Layer number 1 in the chain (optional). |
layer_2 | Layer | Layer number 2 in the chain (optional). |
layer_3 | Layer | Layer number 3 in the chain (optional). |
layer_4 | Layer | Layer number 4 in the chain (optional). |
layer_5 | Layer | Layer number 5 in the chain (optional). |
layer_6 | Layer | Layer number 6 in the chain (optional). |
layer_7 | Layer | Layer number 7 in the chain (optional). |
layer_8 | Layer | Layer number 8 in the chain (optional). |
Outputs
| Port | Type | Description |
|---|---|---|
model | Module | nn.Sequential of the connected layers. |
🧪 Simple CNN
id torch_simple_cnn · Torch · Python export: yes
A complete small image classifier in one node, for when you don't want to wire layers by hand: Conv2D (same padding) -> ReLU -> 2x2 MaxPool -> Flatten -> Linear. Set the image channels and size, the number of filters and kernel size, and the number of classes; the layer sizes are worked out for you. For anything deeper or branching, build the network from the layer nodes.
Inputs
| Port | Type | Description |
|---|---|---|
in_channels | int | Image channels (1 = greyscale, 3 = RGB) (overrides the in_channels field). Overrides the Image channels field when connected. |
image_size | int | Image height and width in pixels (square images) (overrides the image_size field). Overrides the Image size (px) field when connected. |
conv_channels | int | Number of convolution filters (overrides the conv_channels field). Overrides the Conv filters field when connected. |
kernel_size | int | Square kernel side length (overrides the kernel_size field). Overrides the Kernel size field when connected. |
num_classes | int | Number of output classes (overrides the num_classes field). Overrides the Classes field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
model | Module | nn.Sequential classifier — wire into Train Image Classifier. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Image channels | int | 1 | |
| Image size (px) | int | 28 | |
| Conv filters | int | 16 | |
| Kernel size | int | 3 | |
| Classes | int | 10 |
🔥 Tensor
id torch_tensor · Torch · Python export: yes
Convert an array, DataFrame or list into a float32 torch tensor.
Inputs
| Port | Type | Description |
|---|---|---|
data | ndarray | DataFrame | list | Data to convert. |
Outputs
| Port | Type | Description |
|---|---|---|
tensor | Tensor | float32 tensor with the same shape as the data. |
🏋️ Train Image Classifier
id torch_train_image_classifier · Torch · Python export: yes
Train a model as an image classifier: Adam optimiser, cross-entropy loss, one pass over the DataLoader per epoch. Reports progress per epoch / batch and outputs the trained model.
Inputs
| Port | Type | Description |
|---|---|---|
model | Module | Model to train (Sequential or Graph Model). |
dataset | DataLoader | Batches of (inputs, integer class labels). |
lr | float | Adam learning rate (overrides the lr field). Overrides the Learning rate field when connected. |
epochs | int | Number of passes over the data (overrides the epochs field). Overrides the Epochs field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
model | Module | The model after training (same object, updated in place). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Epochs | int | 1 | |
| Learning rate | float | 0.001 |