# Multi Input Multi Output CNN with Flux

**URL:** <https://discourse.julialang.org/t/multi-input-multi-output-cnn-with-flux/114624>\
**Category:** Machine Learning\
**Tags:** question, flux\
**Created:** [May 23, 2024, 12:08pm UTC](https://discourse.julialang.org/t/multi-input-multi-output-cnn-with-flux/114624 "2024-05-23T12:08:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cojiro182](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@cojiro182](https://discourse.julialang.org/u/cojiro182)\
**Post date:** [May 23, 2024, 12:08pm UTC](https://discourse.julialang.org/t/multi-input-multi-output-cnn-with-flux/114624/1 "2024-05-23T12:08:45Z")

</div>

Hi,

I am super new to machine learning and the Flux.jl package and I am having trouble setting up my model. I am effectively trying to train a dataset of 3 images to predict an output of 2 different images. The inputs are of size [1026,514,3,1] and the outputs are of size [1026,514,2,1]. To do this I have been trying to use Join and Split from Fluxperimental.jl but I am getting method errors with my implementation. Am I implementing this correctly? I am also unsure if I am using Upsample correctly but it hasn’t caused any direct issues for me yet. Any advice is sincerely appreciated.

```julia
function m3i2o(max_filters=64, k=5, pad=SamePad(), activation_func=relu, weights_init=Flux.glorot_uniform, mem=gpu)
    function input_layer()
        Chain(
            #downsampling
            Conv((k,k), 3 => Int(round(max_filters/4)), pad=pad, activation_func; init=weights_init),
            MaxPool((2,2)),
            Conv((k,k), Int(round(max_filters/4)) => Int(round(max_filters/2)), pad=pad, activation_func; init=weights_init),
            MaxPool((2,2)),
            Conv((k,k), Int(round(max_filters/2)) => Int(round(max_filters)), pad=pad, activation_func; init=weights_init),
            Conv((k,k), Int(round(max_filters)) => Int(round(max_filters)), pad=pad, activation_func; init=weights_init),
            
            #upsampling
            Upsample(:nearest, scale=(2,2)),
            Conv((k,k), Int(round(max_filters)) => Int(round(max_filters/2)), pad=pad, activation_func; init=weights_init),
            Upsample(:nearest, scale=(2,2)),
            Conv((k,k), Int(round(max_filters/2)) => Int(round(max_filters/4)), pad=pad, activation_func; init=weights_init),
            Conv((k,k), Int(round(max_filters/4)) => 3, pad=pad, activation_func; init=weights_init),
        )
    end

    X = Join(vcat, input_layer())

    model = Chain(
        Split(X, Conv((1,1), 1 => 2, pad=0, activation_func))
    ) |> mem
    return model
end

```
