Exemple #1
0
    def __init__(
            self,
            embedding_dim=128,
            random_dim=128,
            generator_dims=(128, 128),  # 128 -> 128 -> 128
            discriminator_dims=(256, 128, 1),  # datadim * 2 -> 256 -> 128 -> 1
            compress_dims=(),  # datadim -> embedding_dim
            decompress_dims=(),  # embedding_dim -> datadim
            bn_decay=0.99,
            l2scale=0.001,
            pretrain_epoch=200,
            batch_size=1000,
            epochs=2000):

        self.embedding_dim = embedding_dim
        self.random_dim = random_dim
        self.generator_dims = generator_dims
        self.discriminator_dims = discriminator_dims

        self.compress_dims = compress_dims
        self.decompress_dims = decompress_dims
        self.bn_decay = bn_decay
        self.l2scale = l2scale

        self.pretrain_epoch = pretrain_epoch
        self.batch_size = batch_size
        self.epochs = epochs

        self.device = select_device()
        self.transformer = None
Exemple #2
0
    def _synthesizer_function(real_data, metadata):
        metadata_keyword = _synthesizer_dict.get('metadata', '$metadata')
        real_data_keyword = _synthesizer_dict.get('real_data', '$real_data')
        device_keyword = _synthesizer_dict.get('device', '$device')
        device_attribute = _synthesizer_dict.get('device_attribute')
        device = select_device()

        multi_table = 'multi-table' in _synthesizer_dict['modalities']
        if not multi_table:
            table = metadata.get_tables()[0]
            metadata = metadata.get_table_meta(table)
            real_data = real_data[table]

        replace = [
            (metadata_keyword, metadata),
            (real_data_keyword, real_data),
            (device_keyword, device),
        ]

        init_kwargs = _get_kwargs(_synthesizer_dict, 'init', replace)
        fit_kwargs = _get_kwargs(_synthesizer_dict, 'fit', replace)

        instance = synthesizer(**init_kwargs)
        if device_attribute:
            setattr(instance, device_attribute, device)

        instance.fit(**fit_kwargs)

        sampled = instance.sample()
        if not multi_table:
            sampled = {table: sampled}

        return sampled
Exemple #3
0
    def _fit_sample(self, data, metadata):
        LOGGER.info('Fitting %s', self.__class__.__name__)
        model = sdv.timeseries.PAR(table_metadata=metadata, epochs=1024, verbose=False)
        model.device = select_device()
        model.fit(data)

        LOGGER.info('Sampling %s', self.__class__.__name__)
        return model.sample()
Exemple #4
0
    def _fit_sample(self, data, metadata):
        LOGGER.info('Fitting %s', self.__class__.__name__)
        model_kwargs = self._MODEL_KWARGS.copy() if self._MODEL_KWARGS else {}
        model_kwargs.setdefault('cuda', select_device())
        model = self._MODEL(table_metadata=metadata, **model_kwargs)
        model.fit(data)

        LOGGER.info('Sampling %s', self.__class__.__name__)
        return model.sample()
Exemple #5
0
    def __init__(self,
                 random_dim=100,
                 num_channels=64,
                 l2scale=1e-5,
                 batch_size=500,
                 epochs=300):

        self.random_dim = random_dim
        self.num_channels = num_channels
        self.l2scale = l2scale

        self.batch_size = batch_size
        self.epochs = epochs

        self.device = select_device()
Exemple #6
0
    def __init__(
        self,
        embedding_dim=32,
        gen_dim=(128, 128),
        dis_dim=(128, ),
        rec_dim=(128, 128),
        l2scale=1e-6,
        batch_size=500,
        epochs=300
    ):

        self.embedding_dim = embedding_dim
        self.gen_dim = gen_dim
        self.dis_dim = dis_dim
        self.rec_dim = rec_dim

        self.l2scale = l2scale
        self.batch_size = batch_size
        self.epochs = epochs

        self.device = select_device()
Exemple #7
0
 def fit(self, data, metadata):
     self._MODEL_KWARGS = {'cuda': select_device()}
     super().fit(data, metadata)
Exemple #8
0
 def fit(self, data, categorical_columns, ordinal_columns):
     self._MODEL_KWARGS = {'cuda': select_device()}
     super().fit(data, categorical_columns, ordinal_columns)