When implementing custom operators, I found a couple of things that might be improved. So here are my suggestions:
- When I make a custom operator it appears in the preview window as just named “Layer” instead of using the name.
- You have to reimport the model to apply the new operators. This is fine but maybe this should be mentioned in the sample.
- In the Execute function if you just return the value of the second input, say without applying any operators to it, it can just return a tensor with all zeros in it. You might want to do this to bypass a certain operator and then you will get a surprising result. So instead you have to do something like multiply it by 1 before returning it. Not sure if this is a “bug” as such but it is a gotcha to be aware of.
Here is a list of some operators that might make life a little easier:
op.IdentityBasically just returns the input without doing anything to it. This would be useful in the last case above for example.
Tensor.oneIf you want to implement an equation such as 1-x^2 then you need to create a new Tensor(1) at some point and make sure to dispose of it. It might be useful to have a global Tensor.one and Tensor.zero that are just the constants 1 and 0 that you don’t have to dispose of. In general is there a better way with putting constant numbers into op formula?