Closed josh-gree closed 7 years ago
It's actually pretty simple! I'd recommend taking a look at how the convolution layer is implemented. There are a few steps:
__init__()
. Just set initial/default values for your layer's parameters._parse()
. This will get called when the Kurfile is being parsed, and all arguments to your layer are available in self.args
. You can parse/validate arguments here, but do not call into any deep learning libraries (e.g., Keras), because this can have side-effects. The easiest thing is to require that self.args
is a dictionary, and then you can parse out all parameters._build()
. This is where you yield
each layer in turn. Exactly what gets yielded is backend-specific (for Keras, it is the layers themselves; for PyTorch, it is a function which will attach themodules). It is complicated by the fact that, as of Keras 2.0 (yesterday), the Keras API has changed. I want to continue supporting v2.0 as well as v1.x for a little longer, so you'll need to take a look at the v1.2.2 documentation to make sure that the layer properly. This should be really easy for your case, since Deconvolutions (same thing as ConvTranspose) were availabe in Keras 1.kur/containers/layers/__init__.py
so that it will be seen by Kur.simple_model
or embedded_model
example in tests/conftest.py
. This can be as simple as trying to compile a model that uses your layer (again, just grep
around for the embedded
example); it is very little work.Thanks for the pointers have managed to implement it successfully. Only a few modifications needed from convolution layer...
Have not implemented for pytorch or keras v1 but if this would be something you would like as a pull request I could try and do so? I am however unable to find the keras v1 documentation, any ideas where it is?
Awesome! Did you feel it was pretty straightforward? If you have suggestions, please let me know.
I think that it would be great to see a pull request come out of this. The Keras v1 documentation is most easily generated by:
Keras
. Checkout tag 1.2.2
: git checkout 1.2.2
docs/README.md
in the Keras repo. It tells you how to build/view documentation.If you need support for this, let me know.
Yeah it was easy peasy! I will try and get it finished over the next few days...
Hi,
So is it a difficult endeavour to add new layers to the yml specification? I have had a brief look at the code for the dense layer and will have a go at trying to implement myself but any hints/pointers would be very helpful! Specifically I really would like to have access to transposed convolutions...https://keras.io/layers/convolutional/#conv2dtranspose perhaps they are already available?
Thanks
Josh