# Writing a custom encoder

**URL:** <https://discourse.numenta.org/t/writing-a-custom-encoder/759>\
**Category:** Engineering\
**Created:** [June 13, 2016, 8:51pm UTC](https://discourse.numenta.org/t/writing-a-custom-encoder/759 "2016-06-13T20:51:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhilGoddard](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@PhilGoddard](https://discourse.numenta.org/u/PhilGoddard)\
**Post date:** [June 13, 2016, 8:51pm UTC](https://discourse.numenta.org/t/writing-a-custom-encoder/759/1 "2016-06-13T20:51:32Z")

</div>

Can anyone point me towards material describing how to write a custom encoder?

Is there any doc?  
Or is it a matter of hacking the existing code (on a somewhat trial and error basis)?

Thanks,

---

<div class="post-metadata">

**Author:** ![scott](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/scott/32/170_2.png) [@scott](https://discourse.numenta.org/u/scott)\
**Post date:** [June 13, 2016, 11:53pm UTC](https://discourse.numenta.org/t/writing-a-custom-encoder/759/2 "2016-06-13T23:53:49Z")

</div>

The BAMI chapter on encoding should have all the info you need from a theory stand point:

> **[Biological and Machine Intelligence (BAMI)](https://numenta.com/resources/biological-and-machine-intelligence/)**
>
> Biological and Machine Intelligence (BAMI) is a living book authored by Numenta researchers and engineers. Its purpose is to document our theoretical framework for both biological and machine intelligence.

For the actual implementation, assuming you are working in Python you should subclass the Encoder class like the other encoders in NuPIC:

> **[numenta/nupic](https://github.com/numenta/nupic/tree/master/src/nupic/encoders)**
>
> Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex. - numenta/nupic

---

<div class="post-metadata">

**Author:** ![mraptor](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/mraptor/32/4469_2.png) [@mraptor](https://discourse.numenta.org/u/mraptor)\
**Post date:** [June 18, 2016, 7:53pm UTC](https://discourse.numenta.org/t/writing-a-custom-encoder/759/3 "2016-06-18T19:53:47Z")

</div>

You can also look at several encoders I implemented for my project :

> **[vsraptor/bbhtm](https://github.com/vsraptor/bbhtm/tree/master/lib)**
>
> bare bone Hierarchial Temporal Memory. Contribute to vsraptor/bbhtm development by creating an account on GitHub.

they are very simple and I think you will grasp the logic by simply reading the code.

> <https://github.com/vsraptor/bbhtm/blob/master/lib/scalar_encoder.py>
