Equivalent for tf.keras.layers.Lambda in Tensorflow.jl/MXNet.jl

Hi,

I’m porting some code from Python using Tensorflow to Julia. I’m unable to find an equivalent for custom layer in TensorFlow.jl or in MXNet.jl.

This is the exact code I want to translate:

from tensorflow.python.keras.layers import Input, Dense, GaussianNoise, Lambda, Dropout
# .....
# n_channel is a constant with each x is of n_channel length
encoded2        = Lambda( lambda x: np.sqrt(n_channel)*tf.nn.l2_normalize(x,1) )( encoded1 )

How do do this?

With thanks,
Vishnu Raj

Seems Lambda is just a simple encapsulation?

I think make a function in Julia is enougth

something like this?


MyLayer(x) = @mx.chain mx.sqrt(x) => ...

net = @mx.chain OtherLayer(...) =>

    MyLayer(...)