Ejemplo n.º 1
0
class BarkKmeans(ff.BaseModel):
    docs = ff.Feature(
        ff.IteratorNode,
        store=False)

    shuffle = ff.NumpyFeature(
        zounds.ShuffledSamples,
        nsamples=int(1e6),
        needs=docs,
        store=True)

    unitnorm = ff.PickleFeature(
        zounds.UnitNorm,
        needs=shuffle,
        store=False)

    kmeans = ff.PickleFeature(
        zounds.KMeans,
        centroids=128,
        needs=unitnorm,
        store=False)

    pipeline = ff.PickleFeature(
        zounds.PreprocessingPipeline,
        needs=(unitnorm, kmeans),
        store=True)
Ejemplo n.º 2
0
    class LearningPipeline(ff.BaseModel):
        samples = ff.PickleFeature(ff.IteratorNode)

        shuffled = ff.PickleFeature(ShuffledSamples,
                                    nsamples=ff.Var('nsamples'),
                                    dtype=ff.Var('dtype'),
                                    needs=samples)
Ejemplo n.º 3
0
class FreqAdaptiveAutoEncoder(ff.BaseModel):
    """
    Define a processing pipeline to learn a compressed representation of the
    Sound.freq_adaptive feature.  Once this is trained and the pipeline is
    stored, we can apply all the pre-processing steps and the autoencoder
    forward and in reverse.
    """
    docs = ff.Feature(ff.IteratorNode)

    shuffle = ff.PickleFeature(zounds.ShuffledSamples,
                               nsamples=500000,
                               dtype=np.float32,
                               needs=docs)

    mu_law = ff.PickleFeature(zounds.MuLawCompressed, needs=shuffle)

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

    autoencoder = ff.PickleFeature(
        zounds.PyTorchAutoEncoder,
        trainer=zounds.SupervisedTrainer(
            AutoEncoder(),
            loss=nn.MSELoss(),
            optimizer=lambda model: optim.Adam(model.parameters(), lr=0.00005),
            epochs=100,
            batch_size=64,
            holdout_percent=0.5),
        needs=scaled)

    # assemble the previous steps into a re-usable pipeline, which can perform
    # forward and backward transformations
    pipeline = ff.PickleFeature(zounds.PreprocessingPipeline,
                                needs=(mu_law, scaled, autoencoder),
                                store=True)
Ejemplo n.º 4
0
        class Model(ff.BaseModel):
            scaled = ff.PickleFeature(InstanceScaling,
                                      max_value=max_value,
                                      store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(scaled, ),
                                        store=True)
Ejemplo n.º 5
0
        class Model(ff.BaseModel):
            flattened = ff.PickleFeature(Reshape,
                                         new_shape=new_shape,
                                         store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(flattened, ),
                                        store=True)
Ejemplo n.º 6
0
        class Gan(ff.BaseModel):
            scaled = ff.PickleFeature(
                InstanceScaling)

            wgan = ff.PickleFeature(
                PyTorchGan,
                trainer=ff.Var('trainer'),
                needs=scaled)
Ejemplo n.º 7
0
        class Model(ff.BaseModel):
            meanstd = ff.PickleFeature(
                    MeanStdNormalization,
                    store=False)

            pipeline = ff.PickleFeature(
                    PreprocessingPipeline,
                    needs=(meanstd,),
                    store=True)
Ejemplo n.º 8
0
        class Model(ff.BaseModel):
            log = ff.PickleFeature(
                    Log,
                    store=False)

            pipeline = ff.PickleFeature(
                    PreprocessingPipeline,
                    needs=(log,),
                    store=True)
Ejemplo n.º 9
0
        class Model(ff.BaseModel):
            multiply = ff.PickleFeature(
                    Multiply,
                    factor=factor,
                    store=False)

            pipeline = ff.PickleFeature(
                    PreprocessingPipeline,
                    needs=(multiply,),
                    store=True)
Ejemplo n.º 10
0
        class Model(featureflow.BaseModel, Settings):
            unitnorm = featureflow.PickleFeature(UnitNorm, store=False)

            binary = featureflow.PickleFeature(Binarize,
                                               needs=unitnorm,
                                               store=False)

            pipeline = featureflow.PickleFeature(PreprocessingPipeline,
                                                 needs=(unitnorm, binary),
                                                 store=True)
Ejemplo n.º 11
0
        class Model(featureflow.BaseModel, Settings):
            unitnorm = featureflow.PickleFeature(UnitNorm, store=False)

            meanstd = featureflow.PickleFeature(MeanStdNormalization,
                                                needs=unitnorm,
                                                store=False)

            pipeline = featureflow.PickleFeature(PreprocessingPipeline,
                                                 needs=(unitnorm, meanstd),
                                                 store=True)
Ejemplo n.º 12
0
        class Model(featureflow.BaseModel):
            log = featureflow.PickleFeature(Log, store=False)

            meanstd = featureflow.PickleFeature(MeanStdNormalization,
                                                needs=log,
                                                store=False)

            pipeline = featureflow.PickleFeature(PreprocessingPipeline,
                                                 needs=(log, meanstd),
                                                 store=True)
Ejemplo n.º 13
0
        class Model(ff.BaseModel):
            unitnorm = ff.PickleFeature(UnitNorm, store=False)

            kmeans = ff.PickleFeature(KMeans,
                                      centroids=10,
                                      needs=unitnorm,
                                      store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(unitnorm, kmeans),
                                        store=True)
Ejemplo n.º 14
0
        class Model(ff.BaseModel):
            weighted = ff.PickleFeature(Weighted,
                                        weighting=AWeighting(),
                                        store=False)

            scaled = ff.PickleFeature(InstanceScaling,
                                      needs=weighted,
                                      store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(weighted, scaled),
                                        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)
Ejemplo n.º 16
0
        class Pipeline(ff.BaseModel):
            inp = ff.PickleFeature(ff.IteratorNode)

            samples = ff.PickleFeature(ShuffledSamples,
                                       nsamples=500,
                                       needs=inp,
                                       dtype=np.float32)

            scaled = ff.PickleFeature(InstanceScaling, needs=samples)

            network = ff.PickleFeature(PyTorchGan,
                                       apply_network='generator',
                                       trainer=trainer,
                                       needs=scaled)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(scaled, network),
                                        store=True)
Ejemplo n.º 17
0
        class Pipeline(ff.BaseModel):
            inp = ff.PickleFeature(ff.IteratorNode, store=False)

            samples = ff.PickleFeature(ShuffledSamples,
                                       nsamples=500,
                                       dtype=np.float32,
                                       needs=inp,
                                       store=False)

            unitnorm = ff.PickleFeature(UnitNorm, needs=samples, store=False)

            network = ff.PickleFeature(PyTorchAutoEncoder,
                                       trainer=trainer,
                                       needs=unitnorm,
                                       store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(unitnorm, network),
                                        store=True)
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
class DctKmeansWithLogAmplitude(ff.BaseModel):
    """
    A pipeline that applies a logarithmic weighting to the magnitudes of the
    spectrum before learning centroids,
    """
    docs = ff.Feature(
            ff.IteratorNode,
            store=False)

    # randomize the order of the data
    shuffle = ff.NumpyFeature(
            zounds.ReservoirSampler,
            nsamples=1e6,
            needs=docs,
            store=True)

    log = ff.PickleFeature(
            zounds.Log,
            needs=shuffle,
            store=False)

    # give each frame unit norm, since we care about the shape of the spectrum
    # and not its magnitude
    unit_norm = ff.PickleFeature(
            zounds.UnitNorm,
            needs=log,
            store=False)

    # learn 512 centroids, or basis functions
    kmeans = ff.PickleFeature(
            zounds.KMeans,
            centroids=512,
            needs=unit_norm,
            store=False)

    # assemble the previous steps into a re-usable pipeline, which can perform
    # forward and backward transformations
    pipeline = ff.PickleFeature(
            zounds.PreprocessingPipeline,
            needs=(log, unit_norm, kmeans),
            store=True)
Ejemplo n.º 21
0
    class RichardNixonIdentifier(ff.BaseModel):
        docs = ff.PickleFeature(ff.IteratorNode, store=False)

        shuffled = ff.PickleFeature(zounds.ShuffledSamples,
                                    nsamples=int(1e5),
                                    multiplexed=True,
                                    dtype=np.float32,
                                    needs=docs,
                                    store=False)

        mu_law_source = ff.PickleFeature(zounds.MuLawCompressed,
                                         needs=shuffled.aspect('data'),
                                         store=False)

        scaled_source = ff.PickleFeature(zounds.InstanceScaling,
                                         needs=mu_law_source,
                                         store=False)

        network = ff.PickleFeature(
            zounds.PyTorchNetwork,
            trainer=zounds.SupervisedTrainer(
                model=Discriminator(),
                loss=nn.BCELoss(),
                optimizer=lambda model: optim.Adam(model.parameters(),
                                                   lr=0.00005),
                epochs=epochs,
                batch_size=64,
                holdout_percent=0.5),
            needs=dict(data=scaled_source, labels=shuffled.aspect('labels')),
            store=False)

        pipeline = ff.PickleFeature(zounds.PreprocessingPipeline,
                                    needs=(mu_law_source, scaled_source,
                                           network),
                                    store=True)
Ejemplo n.º 22
0
        class Pipeline(ff.BaseModel):
            inp = ff.PickleFeature(ff.IteratorNode, store=False)

            samples = ff.PickleFeature(ShuffledSamples,
                                       nsamples=500,
                                       multiplexed=True,
                                       dtype=np.float32,
                                       needs=inp,
                                       store=False)

            unitnorm = ff.PickleFeature(UnitNorm,
                                        needs=samples.aspect('data'),
                                        store=False)

            hard_labels = ff.PickleFeature(Binarize,
                                           needs=samples.aspect('labels'),
                                           store=False)

            network = ff.PickleFeature(PyTorchNetwork,
                                       trainer=trainer,
                                       needs=dict(data=unitnorm,
                                                  labels=hard_labels),
                                       store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(unitnorm, network),
                                        store=True)
Ejemplo n.º 23
0
class DctKmeans(ff.BaseModel):
    """
    A pipeline that does example-wise normalization by giving each example
    unit-norm, and learns 512 centroids from those examples.
    """
    docs = ff.Feature(
            ff.IteratorNode,
            store=False)

    # randomize the order of the data
    shuffle = ff.NumpyFeature(
            zounds.ReservoirSampler,
            nsamples=1e6,
            needs=docs,
            store=True)

    # give each frame unit norm, since we care about the shape of the spectrum
    # and not its magnitude
    unit_norm = ff.PickleFeature(
            zounds.UnitNorm,
            needs=shuffle,
            store=False)

    # learn 512 centroids, or basis functions
    kmeans = ff.PickleFeature(
            zounds.KMeans,
            centroids=512,
            needs=unit_norm,
            store=False)

    # assemble the previous steps into a re-usable pipeline, which can perform
    # forward and backward transformations
    pipeline = ff.PickleFeature(
            zounds.PreprocessingPipeline,
            needs=(unit_norm, kmeans),
            store=True)
Ejemplo n.º 24
0
    class Rbm(featureflow.BaseModel, Settings):
        iterator = featureflow.Feature(Iterator, store=False)

        shuffle = featureflow.NumpyFeature(ReservoirSampler,
                                           nsamples=1000,
                                           needs=iterator,
                                           store=True)

        unitnorm = featureflow.PickleFeature(UnitNorm,
                                             needs=shuffle,
                                             store=False)

        meanstd = featureflow.PickleFeature(MeanStdNormalization,
                                            needs=unitnorm,
                                            store=False)

        rbm = featureflow.PickleFeature(KMeans,
                                        centroids=3,
                                        needs=meanstd,
                                        store=False)

        pipeline = featureflow.PickleFeature(PreprocessingPipeline,
                                             needs=(unitnorm, meanstd, rbm),
                                             store=True)
Ejemplo n.º 25
0
class GanPipeline(ff.BaseModel):
    docs = ff.PickleFeature(ff.IteratorNode, store=False)

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

    mu_law = ff.PickleFeature(zounds.MuLawCompressed,
                              needs=shuffled,
                              store=False)

    scaled = ff.PickleFeature(zounds.InstanceScaling,
                              needs=mu_law,
                              store=False)

    network = ff.PickleFeature(
        zounds.PyTorchGan,
        trainer=zounds.GanTrainer(
            generator=Generator(),
            discriminator=Discriminator(),
            loss=nn.BCELoss(),
            generator_optim_func=lambda model: optim.Adam(
                model.parameters(), lr=0.0002, betas=(0.5, 0.999)),
            discriminator_optim_func=lambda model: optim.Adam(
                model.parameters(), lr=0.00005, betas=(0.5, 0.999)),
            latent_dimension=(LATENT_DIM, ),
            epochs=500,
            batch_size=64),
        needs=scaled,
        store=False)

    pipeline = ff.PickleFeature(zounds.PreprocessingPipeline,
                                needs=(mu_law, scaled, network),
                                store=True)
Ejemplo n.º 26
0
class SimHashPipelineWithPackedBits(ff.BaseModel):
    simhash = ff.PickleFeature(SimHash, packbits=True, bits=1024)

    pipeline = ff.PickleFeature(PreprocessingPipeline,
                                needs=(simhash, ),
                                store=True)
Ejemplo n.º 27
0
class SimHashPipeline(ff.BaseModel):
    simhash = ff.PickleFeature(SimHash, bits=128)

    pipeline = ff.PickleFeature(PreprocessingPipeline,
                                needs=(simhash, ),
                                store=True)
Ejemplo n.º 28
0
        class Model(ff.BaseModel):
            sliced = ff.PickleFeature(Slicer, slicex=slicex, store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(sliced, ),
                                        store=True)
Ejemplo n.º 29
0
class Document(ff.BaseModel):
    l = ff.PickleFeature(SklearnModel, model=MockSklearnModel())

    pipeline = ff.PickleFeature(PreprocessingPipeline, needs=(l, ), store=True)
Ejemplo n.º 30
0
        class Model(ff.BaseModel):
            unitnorm = ff.PickleFeature(UnitNorm, store=False)

            pipeline = ff.PickleFeature(PreprocessingPipeline,
                                        needs=(unitnorm, ),
                                        store=True)