# How to set up convolution layers in Knet.jl vs Flux.jl?

**URL:** <https://discourse.julialang.org/t/how-to-set-up-convolution-layers-in-knet-jl-vs-flux-jl/46983>\
**Category:** New to Julia\
**Tags:** machinevision\
**Created:** [September 21, 2020, 6:44am UTC](https://discourse.julialang.org/t/how-to-set-up-convolution-layers-in-knet-jl-vs-flux-jl/46983 "2020-09-21T06:44:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 21, 2020, 6:44am UTC](https://discourse.julialang.org/t/how-to-set-up-convolution-layers-in-knet-jl-vs-flux-jl/46983/1 "2020-09-21T06:44:54Z")

</div>

I have trouble understaind the Knet.jl docs

For example

```julia
conv4(w, x; kwargs...)
Execute convolutions or cross-correlations using filters specified with w over tensor x.

If w has dimensions (W1,W2,...,Cx,Cy) and x has dimensions (X1,X2,...,Cx,N), the result y will have dimensions (Y1,Y2,...,Cy,N) where Cx is the number of input channels, Cy is the number of output channels, N is the number of instances, and Wi,Xi,Yi are spatial dimensions with Yi determined by:

```

to set up a convolution layer in Flux.jl it’s

```julia
Conv((2,2), 1=>16, relu)

```

I know that I am applying a `2x2` convolution and making 16 output channels (so 16 filters) from 1 channel. Whereas I can’t heads and tails of the doc in Knet.jl at all.

Flux.jl seems to be closer to Keras in design.

How do I a 2 by 2 convolution filter in Knet.jl?

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [September 21, 2020, 9:30am UTC](https://discourse.julialang.org/t/how-to-set-up-convolution-layers-in-knet-jl-vs-flux-jl/46983/2 "2020-09-21T09:30:34Z")

</div>

Looks like it’s based on the size of `w`  
[http://denizyuret.github.io/Knet.jl/v0.8/cnn.html#conv\_dims-1](http://denizyuret.github.io/Knet.jl/v0.8/cnn.html#conv_dims-1)
