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

**URL:** <https://discourse.julialang.org/t/equivalent-for-tf-keras-layers-lambda-in-tensorflow-jl-mxnet-jl/8511>\
**Category:** Machine Learning\
**Tags:** tensorflow\
**Created:** [January 21, 2018, 11:14pm UTC](https://discourse.julialang.org/t/equivalent-for-tf-keras-layers-lambda-in-tensorflow-jl-mxnet-jl/8511 "2018-01-21T23:14:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Post date:** [January 21, 2018, 11:14pm UTC](https://discourse.julialang.org/t/equivalent-for-tf-keras-layers-lambda-in-tensorflow-jl-mxnet-jl/8511/1 "2018-01-21T23:14:20Z")

</div>

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:

```julia
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

---

<div class="post-metadata">

**Author:** ![iblis17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iblis17/32/649_2.png) [@iblis17](https://discourse.julialang.org/u/iblis17)\
**Post date:** [January 24, 2018, 4:55pm UTC](https://discourse.julialang.org/t/equivalent-for-tf-keras-layers-lambda-in-tensorflow-jl-mxnet-jl/8511/2 "2018-01-24T16:55:44Z")

</div>

Seems `Lambda` is just a simple encapsulation?

I think make a function in Julia is enougth

something like this?

```julia

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

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

    MyLayer(...)

```
