# Reshaping outputs between layers in Flux.jl

**URL:** https://discourse.julialang.org/t/reshaping-outputs-between-layers-in-flux-jl/17838
**Category:** Machine Learning
**Created:** [November 22, 2018, 12:44am UTC](https://discourse.julialang.org/t/reshaping-outputs-between-layers-in-flux-jl/17838 "2018-11-22T00:44:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Rademcaher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rademcaher/32/7420_2.png) [@Rademcaher](https://discourse.julialang.org/u/Rademcaher)
#### Post date: [November 22, 2018, 12:44am UTC](https://discourse.julialang.org/t/reshaping-outputs-between-layers-in-flux-jl/17838/1 "2018-11-22T00:44:08Z")

</div>

The input to my network are N x 2 arrays and I’d like to implement a Dense layer, followed by a convolution. This requires reshaping the output of the dense layer. The forward pass seems to work fine, but I think there’s an error on the backprop somewhere. Any help is appreciated.

```julia
m = Chain(
    Dense(N, N, relu),
    x -> reshape(x, N, 1, 2, 1),
    Conv((2,1), 2=>1, relu),
    x -> x[:],
    Dense(N-1, N, relu)) |> gpu

m(train[1][1])

loss(x, y) = Flux.mse(m(x), y)

```

This is the error, some kind of dimension mismatch?:

```julia
MethodError: no method matching *(::TrackedArray{…,CuArray{Float32,2}}, ::CuArray{Float32,3})
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...) at operators.jl:502

```

---

<div class="post-metadata">

### Author: ![y4lu](https://avatars.discourse-cdn.com/v4/letter/y/47e85d/32.png) [@y4lu](https://discourse.julialang.org/u/y4lu)
#### Post date: [November 22, 2018, 1:02am UTC](https://discourse.julialang.org/t/reshaping-outputs-between-layers-in-flux-jl/17838/2 "2018-11-22T01:02:41Z")

</div>

Probably a type mismatch, multiply isn’t currently implemented between types (CuArray, Tracked{CuArray}) is basically what it’s telling us

See the first example here [http://fluxml.ai/Flux.jl/stable/training/optimisers.html](http://fluxml.ai/Flux.jl/stable/training/optimisers.html) for tracking a gradient  
Making y a flux param will probably work
