Ejemplo n.º 1
0
def create(input_width, input_height, input_channels=1):
    """ Vel factory function """
    def instantiate(**_):
        return DoubleNatureCnn(input_width=input_width,
                               input_height=input_height,
                               input_channels=input_channels)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 2
0
def create(input_length, hidden_layers, activation='tanh', normalization=None):
    """ Vel factory function """
    def instantiate(**_):
        return MLP(input_length=input_length,
                   hidden_layers=hidden_layers,
                   activation=activation,
                   normalization=normalization)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 3
0
def create(input_width, input_height, input_channels=1, output_dim=512):
    """ Vel factory function """
    def instantiate(**_):
        return NatureCnn(input_width=input_width,
                         input_height=input_height,
                         input_channels=input_channels,
                         output_dim=output_dim)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 4
0
def create(blocks, mode='basic', inplanes=16, divisor=4, num_classes=1000):
    """ Vel factory function """
    block_dict = {
        'basic': BasicBlock,
        'bottleneck': Bottleneck
    }

    def instantiate(**_):
        return ResNetV2(block_dict[mode], blocks, inplanes=inplanes, divisor=divisor, num_classes=num_classes)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 5
0
def create(input_shape):
    """ Vel factory function """
    if isinstance(input_shape, numbers.Number):
        input_shape = (input_shape, )
    elif not isinstance(input_shape, tuple):
        input_shape = tuple(input_shape)

    def instantiate(**_):
        return NormalizeObservations(input_shape)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 6
0
def create(alphabet_size: int,
           output_dim: int,
           pretrained: bool = False,
           frozen: bool = False,
           source: TextData = None):
    """ Vel factory function """
    def instantiate(**_):
        return EmbeddingInput(alphabet_size,
                              output_dim,
                              pretrained=pretrained,
                              frozen=frozen,
                              source=source)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 7
0
def create(input_block: ModelFactory,
           rnn_type: str,
           hidden_layers: typing.List[int],
           output_dim: int,
           dropout=0.0):
    """ Vel factory function """
    def instantiate(**_):
        return MultilayerRnnSequenceModel(input_block.instantiate(),
                                          rnn_type=rnn_type,
                                          hidden_layers=hidden_layers,
                                          output_dim=output_dim,
                                          dropout=dropout)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 8
0
def create(input_width,
           input_height,
           input_channels=1,
           output_dim=512,
           initial_std_dev=0.4,
           factorized_noise=True):
    """ Vel factory function """
    def instantiate(**_):
        return NoisyNatureCnn(input_width=input_width,
                              input_height=input_height,
                              input_channels=input_channels,
                              output_dim=output_dim,
                              initial_std_dev=initial_std_dev,
                              factorized_noise=factorized_noise)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 9
0
def create(input_width,
           input_height,
           input_channels=1,
           rnn_type='lstm',
           cnn_output_dim=512,
           hidden_units=128):
    """ Vel factory function """
    def instantiate(**_):
        return NatureCnnRnnBackbone(input_width=input_width,
                                    input_height=input_height,
                                    input_channels=input_channels,
                                    rnn_type=rnn_type,
                                    cnn_output_dim=cnn_output_dim,
                                    hidden_units=hidden_units)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 10
0
def create(blocks,
           mode='basic',
           inplanes=64,
           cardinality=4,
           image_features=64,
           divisor=4,
           num_classes=1000):
    """ Vel factory function """
    block_dict = {
        # 'basic': BasicBlock,
        'bottleneck': ResNeXtBottleneck
    }

    def instantiate(**_):
        return ResNeXt(block_dict[mode],
                       blocks,
                       inplanes=inplanes,
                       image_features=image_features,
                       cardinality=cardinality,
                       divisor=divisor,
                       num_classes=num_classes)

    return ModelFactory.generic(instantiate)
def create(input_block: ModelFactory,
           rnn_type: str,
           output_dim: int,
           rnn_layers: typing.List[int],
           rnn_dropout: float = 0.0,
           bidirectional: bool = False,
           linear_layers: typing.List[int] = None,
           linear_dropout: float = 0.0):
    """ Vel factory function """
    if linear_layers is None:
        linear_layers = []

    def instantiate(**_):
        return MultilayerRnnSequenceClassification(
            input_block=input_block.instantiate(),
            rnn_type=rnn_type,
            output_dim=output_dim,
            rnn_layers=rnn_layers,
            rnn_dropout=rnn_dropout,
            bidirectional=bidirectional,
            linear_layers=linear_layers,
            linear_dropout=linear_dropout)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 12
0
def create(fc_layers=None, dropout=None, pretrained=True):
    """ Vel factory function """
    def instantiate(**_):
        return Resnet34(fc_layers, dropout, pretrained)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 13
0
def create(alphabet_size: int):
    """ Vel factory function """
    def instantiate(**_):
        return OneHotEncodingInput(alphabet_size)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 14
0
def create(img_rows, img_cols, img_channels, num_classes):
    """ Vel factory function """
    def instantiate(**_):
        return Net(img_rows, img_cols, img_channels, num_classes)

    return ModelFactory.generic(instantiate)
Ejemplo n.º 15
0
def create():
    """ Vel factory function """
    return ModelFactory.generic(ImageToTensor)
Ejemplo n.º 16
0
def create():
    """ Vel factory function """
    def instantiate(**_):
        return Identity()

    return ModelFactory.generic(instantiate)