Esempio n. 1
0
    class LearningPipeline(ff.BaseModel):
        samples = ff.PickleFeature(ff.IteratorNode)

        shuffled = ff.PickleFeature(ShuffledSamples,
                                    nsamples=ff.Var('nsamples'),
                                    dtype=ff.Var('dtype'),
                                    needs=samples)
Esempio n. 2
0
    class InfiniteLearningPipeline(cls):
        dataset = ff.Feature(
            InfiniteSampler,
            nsamples=ff.Var('nsamples'),
            dtype=ff.Var('dtype'),
            feature_filter=ff.Var('feature_filter'),
            parallel=ff.Var('parallel'))

        pipeline = ff.ClobberPickleFeature(
            PreprocessingPipeline,
            needs=cls.features,
            store=True)

        @classmethod
        def load_network(cls):
            if not cls.exists():
                raise RuntimeError('No network has been trained or saved')

            instance = cls()
            for p in instance.pipeline:
                try:
                    return p.network
                except AttributeError:
                    pass

            raise RuntimeError('There is no network in the pipeline')
Esempio n. 3
0
        class Gan(ff.BaseModel):
            scaled = ff.PickleFeature(
                InstanceScaling)

            wgan = ff.PickleFeature(
                PyTorchGan,
                trainer=ff.Var('trainer'),
                needs=scaled)
Esempio n. 4
0
class EmbeddingPipeline(BasePipeline, Settings):
    scaled = ff.PickleFeature(zounds.InstanceScaling,
                              needs=BasePipeline.shuffled)

    embedding = ff.PickleFeature(
        zounds.PyTorchNetwork,
        trainer=ff.Var('trainer'),
        post_training_func=(lambda x: x[:, anchor_slice]),
        needs=dict(data=scaled))

    unitnorm = ff.PickleFeature(zounds.UnitNorm, needs=embedding)

    simhash = ff.PickleFeature(zounds.SimHash,
                               bits=ff.Var('bits'),
                               packbits=True,
                               needs=unitnorm)

    pipeline = ff.PickleFeature(zounds.PreprocessingPipeline,
                                needs=(scaled, embedding, unitnorm, simhash),
                                store=True)
class CategoricalAutoEncoderPipeline(ff.BaseModel):
    samples = ff.PickleFeature(ff.IteratorNode)

    shuffled = ff.PickleFeature(zounds.ShuffledSamples,
                                nsamples=int(1e5),
                                dtype=np.float32,
                                needs=samples)

    autoencoder = ff.PickleFeature(zounds.PyTorchAutoEncoder,
                                   trainer=ff.Var('trainer'),
                                   needs=shuffled)

    pipeline = ff.PickleFeature(zounds.PreprocessingPipeline,
                                needs=(autoencoder, ),
                                store=True)
Esempio n. 6
0
class Gan(ff.BaseModel):
    samples = ff.PickleFeature(ff.IteratorNode)

    shuffled = ff.PickleFeature(zounds.ShuffledSamples,
                                nsamples=int(1e5),
                                dtype=np.float32,
                                needs=samples)

    scaled = ff.PickleFeature(zounds.InstanceScaling, needs=shuffled)

    wgan = ff.PickleFeature(zounds.PyTorchGan,
                            trainer=ff.Var('trainer'),
                            needs=scaled)

    pipeline = ff.PickleFeature(zounds.PreprocessingPipeline,
                                needs=(
                                    scaled,
                                    wgan,
                                ),
                                store=True)