def __init__(self,
                 in_channels,
                 hidden_channels1,
                 hidden_channels2,
                 kernel_size,
                 include_original,
                 include_time,
                 sig_depth,
                 out_channels,
                 batch_norm=False):
        """
        Inputs:
            in_channels: As SignatureModel.
            hidden_channels1: How large to make certain hidden channels within the model.
            hidden_channels2: How large to make certain hidden channels within the model.
            kernel_size: How far to look back in time.
            include_original: As SignatureModel.
            include_time: As SignatureModel.
            sig_depth: As SignatureModel.
            out_channels: As SignatureModel.
        """
        super().__init__()
        self.kernel_size = kernel_size
        self.batch_norm = batch_norm
        self.padding1 = torch.nn.ConstantPad1d((kernel_size - 1, 0), 0)
        self.augment1 = signatory.Augment(in_channels=in_channels,
                                          layer_sizes=(hidden_channels1,
                                                       hidden_channels1,
                                                       hidden_channels2),
                                          kernel_size=kernel_size,
                                          include_original=include_original,
                                          include_time=include_time)
        self.signature1 = signatory.Signature(depth=sig_depth, stream=True)

        sig_hidden_channels = hidden_channels2
        if include_original:
            sig_hidden_channels += in_channels
        if include_time:
            sig_hidden_channels += 1
        sig_channels1 = signatory.signature_channels(
            channels=sig_hidden_channels, depth=sig_depth)
        self.padding2 = torch.nn.ConstantPad1d((kernel_size - 1, 0), 0)
        self.augment2 = signatory.Augment(in_channels=sig_channels1,
                                          layer_sizes=(hidden_channels1,
                                                       hidden_channels1,
                                                       hidden_channels2),
                                          kernel_size=kernel_size,
                                          include_original=False,
                                          include_time=False)
        self.signature2 = signatory.Signature(depth=sig_depth, stream=False)

        sig_channels2 = signatory.signature_channels(channels=hidden_channels2,
                                                     depth=sig_depth)
        self.linear = torch.nn.Linear(sig_channels2, out_channels)

        if self.batch_norm:
            self.bn1 = nn.BatchNorm1d(num_features=sig_channels1)
            self.bn2 = nn.BatchNorm1d(num_features=sig_channels2)
예제 #2
0
 def __init__(self, in_channels, out_dimension, sig_depth):
     super(SigNet, self).__init__()
     self.augment = signatory.Augment(in_channels=in_channels,
                                      layer_sizes=(),
                                      kernel_size=1,
                                      include_original=True,
                                      include_time=True)
     self.signature = signatory.Signature(depth=sig_depth)
     # +1 because signatory.Augment is used to add time as well
     sig_channels = signatory.signature_channels(channels=in_channels + 1,
                                                 depth=sig_depth)
     self.linear = torch.nn.Linear(sig_channels, out_dimension)
예제 #3
0
    def __init__(self, in_channels, out_dimension, sig_depth):
        super(SigNet3, self).__init__()
        self.augment1 = signatory.Augment(in_channels=in_channels,
                                          layer_sizes=(8, 8, 4),
                                          kernel_size=4,
                                          include_original=True,
                                          include_time=True)
        self.signature1 = signatory.Signature(depth=sig_depth, stream=True)

        # +5 because self.augment1 is used to add time, and 4 other
        # channels, as well
        sig_channels1 = signatory.signature_channels(channels=in_channels + 5,
                                                     depth=sig_depth)
        self.augment2 = signatory.Augment(in_channels=sig_channels1,
                                          layer_sizes=(8, 8, 4),
                                          kernel_size=4,
                                          include_original=False,
                                          include_time=False)
        self.signature2 = signatory.Signature(depth=sig_depth, stream=False)

        # 4 because that's the final layer size in self.augment2
        sig_channels2 = signatory.signature_channels(channels=4,
                                                     depth=sig_depth)
        self.linear = torch.nn.Linear(sig_channels2, out_dimension)
예제 #4
0
    def __init__(self, input_dim, latent_dim, gru_n_layers = 2, augment_chs = 8):
        super().__init__()
        self.latent_dim = latent_dim
        self.augment1 = signatory.Augment(in_channels=input_dim,
                          layer_sizes=(32, augment_chs),
                          kernel_size=1,
                          include_original=True,
                          include_time=True)

        self.signature1 = signatory.Signature(depth=2,
                             stream=True)

        sig_channels1 = signatory.signature_channels(channels=input_dim + augment_chs + 1,
                                              depth=2)

        self.gru = nn.GRU(input_size = sig_channels1, hidden_size = latent_dim, num_layers = gru_n_layers, batch_first = True)
예제 #5
0
    def __init__(self, latent_dim, output_dim, decoder_hidden_units = 64):
        super().__init__()
        self.latent_dim = latent_dim
        self.decoder_hidden_units = decoder_hidden_units
        self.augment2 = signatory.Augment(in_channels=latent_dim,
                                  layer_sizes=(64, 32),
                                  kernel_size=1,
                                  include_original=False,
                                  include_time=False)

        self.signature2 = signatory.Signature(depth=2,
                             stream=True)

        sig_channels2 = signatory.signature_channels(channels= 32,
                                              depth=2)
        
        self.linear1 = nn.Linear(in_features = sig_channels2, out_features = decoder_hidden_units)
        self.linear2 = nn.Linear(in_features = decoder_hidden_units, out_features = output_dim)