Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (22 sloc) 782 Bytes

Writing Custom Transforms

Writing a custom transform is simple and straighforward. A transformer must only implement one function, transform. After initialization, transformers should be stateless so they may be used in multiple pipelines, and each pipeline can be executed many times. Keeping transformers stateless also helps with memory consumption, which can become a problem as the size of input grows.

Here is an example transform class implementation:

import hidi


class TimesTwoTransform(object):
    def transform(self, inp, **kwargs):
        # Transform input
        return inp*2, kwargs

pipeline = hidi.pipeline.Pipeline([
    ...,
    TimesTwoTransform(),
    ...
])

pipeline.run()