# Use DataLoader in Flux DimensionMismatch

**URL:** <https://discourse.julialang.org/t/use-dataloader-in-flux-dimensionmismatch/99810>\
**Category:** Machine Learning\
**Tags:** question, flux, dataframes\
**Created:** [June 3, 2023, 1:46pm UTC](https://discourse.julialang.org/t/use-dataloader-in-flux-dimensionmismatch/99810 "2023-06-03T13:46:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ordens\_Ritter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ordens_ritter/32/50363_2.png) [@Ordens\_Ritter](https://discourse.julialang.org/u/Ordens_Ritter)\
**Post date:** [June 3, 2023, 1:46pm UTC](https://discourse.julialang.org/t/use-dataloader-in-flux-dimensionmismatch/99810/1 "2023-06-03T13:46:38Z")

</div>

I am trying to train this tiny net in Flux:

```julia
	NN = Chain(
		Dense(2 => 16, tanh),
		Dense(16 => 16, tanh),
		Dense(16 => 1)
	) |> f64

```

I the data comes from a single DataFrame, that I mask, convert the temp to Kelvin and feed this into the DataLoader.  
But when I want to train the batches

I get the error: `DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 3 and 64`  
That the dimensions do not match. Which I do not unterstand.

```julia
train_mask = 1: Int.(length(static_df.T1)//2)

	
x_train = static_df[train_mask, [:Q1, :T1]]
x_train.T1 = x_train.T1 .|> celsius2kelvin
x_train = x_train|> Matrix
x_train = [x for x in eachrow(x_train)]

y_train = static_df[train_mask, :T1] .|> celsius2kelvin

loader = Flux.DataLoader((data=x_train, label=y_train), batchsize=64, shuffle=false, partial=false)
	
η = 0.001
opt = Flux.setup(Adam(η), NN)
epochs = 5
lossₘ(ŷ, y) = sum((ŷ .- y).^2)
	
for i in 1:epochs
	for mini_batch ∈ loader
		train!(lossₘ, NN, mini_batch, opt)
	end
end

```

1. How can I correctly load to data and  
2.How can I see the progressing loss during the training?
