trw.arch.darts_cell

Module Contents

Classes

MixedLayer

Represents a mixture of weighted primitive units

SpecialParameter

Tag a parameter as special such as DARTS parameter. These should be handled differently

Cell

Base class for all neural network modules.

Functions

default_cell_output(node_outputs, nb_outputs_to_use=4)

_identity(x)

class trw.arch.darts_cell.MixedLayer(primitives, c, stride)

Bases: torch.nn.Module

Represents a mixture of weighted primitive units

forward(self, x, weights)
trw.arch.darts_cell.default_cell_output(node_outputs, nb_outputs_to_use=4)
class trw.arch.darts_cell.SpecialParameter

Bases: torch.nn.Parameter

Tag a parameter as special such as DARTS parameter. These should be handled differently depending on the phase: training the DARTS cell parameters or the weight parameters

trw.arch.darts_cell._identity(x)
class trw.arch.darts_cell.Cell(primitives, cpp, cp, c, is_reduction, is_reduction_prev, internal_nodes=4, cell_merge_output_fn=default_cell_output, weights=None, with_preprocessing=True, genotype=None)

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Variables

training (bool) – Boolean represents whether this module is in training or evaluation mode.

_create_weights(self, primitives, weights)

Create the weights. Do not store them directly in the model parameters else they will be optimized too!

forward(self, parents)
get_weights(self)
Returns

The primitive weights for this cell. This is useful if we want to share the weights among multiple cells

get_genotype(self)
Returns

The genotype of the cell given the current primitive weighting