Questions tagged [flux.jl]

For questions related to flux.jl – a machine learning library for Julia programming language.

Filter by
Sorted by
Tagged with
0 votes
0 answers
30 views

DimensionMismatch: matrix A has dimensions (100,7), matrix B has dimensions (10,7) with the following julia code

I am new to julia and I am having trouble getting this training loop to work, my inputs are as follows, inputs is the 7-segments of a digital clock and target output is what the nn is trying to learn. ...
Aaron King King's user avatar
0 votes
1 answer
40 views

Flux UndefVarError: `setup` not defined

I have the following issue when running the following code, hparams = HyperParams() gen = generator() enc = encoder() dec = decoder() gen_opt = Flux.setup(Flux.Adam(hparams.lr_gen), gen) enc_opt = ...
Jose Manuel de Frutos's user avatar
0 votes
1 answer
65 views

Accelerate/Parallelize the training ML algorithm in Flux

I am experimenting with a machine learning method. My goal is to define a loss function that can evaluate the convergence of the model towards a uniform data distribution. I generate K random ...
Jose Manuel de Frutos's user avatar
1 vote
0 answers
59 views

ERROR: UndefVarError: `setup` not defined when loading setup function in flux

I am using M1 mac (if that helps) and when I tried loading the setup function flux.jl and got the following error. UndefVarError setup not defined The flux version I am using is 0.13.4. I created a ...
imantha's user avatar
  • 2,758
1 vote
1 answer
85 views

What is a model in Julia Flux 0.13 and higher?

(also posted in Julia discourse https://discourse.julialang.org/t/what-is-a-model-in-julia-flux-0-13-and-higher/100653) I want to use Julia Flux for machine learning with custom models (not neural ...
Yrogirg's user avatar
  • 2,321
0 votes
0 answers
68 views

How to get first derivative of input wrt output of a neural network in Julia Flux? (for Sobolov training)

I have a dataset with input images x_train, an objective value corresponding to each image y_train, and the set of derivatives of y_train wrt x_train, dc_train. I would like to train a CNN using this ...
shantha's user avatar
0 votes
0 answers
45 views

Error in Flux when calculating the gradient due to an in-place operation

I'm diving into Flux.jl for my research. My objective is to define a loss function that would measure, so to speak, the convergence of the model towards a uniform data distribution. I generate K ...
Jose Manuel de Frutos's user avatar
1 vote
1 answer
72 views

Reparametrization trick in Flux.jl

Does Flux.jl have an equivalent to rsample in PyTorch that automatically implements these stochastic/policy gradients. That way the reparameterized sample becomes differentiable.
Jose Manuel de Frutos's user avatar
2 votes
0 answers
38 views

Is there a way to impose a constraint on the output of a Flux neural network model?

Suppose that I have the observed data $y_i\sim N(0,1/w(x_i)), $ where $x_i=i$ for $i=1,...,100$. I define the true function $w(x_i)=(x_i-50)^2$ and hope to recover this function with a Flux neural ...
Ron Snow's user avatar
  • 249
1 vote
1 answer
75 views

Stepwise decrease GPU utility followed by out of memory error

I am running a 3D image segmentation deep learning training pipeline on a GCloud VM and am noticing a stepwise decrease of the GPU utility after about 25 epochs and an out of memory error after 32 ...
ita's user avatar
  • 115
0 votes
0 answers
69 views

Compile time in Julia when training a model in Flux is too high

I'm training a simple model on Julia using Flux and I'm trying to compare the training times between training on GPU and on CPU (also between Julia and Python using the same model in Python with ...
Luis.Alberto's user avatar
0 votes
2 answers
146 views

Same model performs very diferent in Keras and Flux

In a class I'm taking, the professor gave us two datasets, one of 301 late-type galaxies and the other one of 301 early-type galaxies, and we build a model in Keras so it can differentiate them: ...
Luis.Alberto's user avatar
0 votes
0 answers
66 views

Accuracy and gradient update not within the same training loop

I am following the example mlp_mnist.jl from Flux model zoo and I am a little confused with the accuracy computation and train functions. The accuracy computation function loops over the dataloader ...
imantha's user avatar
  • 2,758
0 votes
0 answers
69 views

Why the Loss function does not decrease significantly in Flux.jl

After trying some optimizations on activation function and epochs value , it is not possible to fit the model to y data which is a function of the input data. using Flux, Plots, Statistics x = Array{...
Bouarfa Mahi's user avatar
4 votes
1 answer
316 views

Julia Flux withgradient operation

I am a newbie to Julia and Flux with some experience in Tensorflow Keras and python. I tried to use the Flux.withgradient command to write a user-defined training function with more flexibility. Here ...
PokeLu's user avatar
  • 807
1 vote
1 answer
253 views

Why am I getting a "Mutating arrays is not supported" error here?

Here's a minimal working example. using Flux myvector = [] for i in 1:3 push!(myvector, 0.1 * i) #Produces a vector [0.1, 0.2, 0.3] end Q = Chain(Dense(3, 64, relu), Dense(64, 32, relu), Dense(...
Allure's user avatar
  • 261
3 votes
0 answers
132 views

simple example returns MethodError: no method matching Dense(::Pair{Int64, Int64})

I am running through basic examples for Flux, and I am getting MethodErrors when running code verbatim through the REPL. I am using a fresh REPL and am on VERSION 1.8.2 for linux. julia> using ...
Matthew Cr's user avatar
1 vote
0 answers
319 views

Using the GPU with Lux and NeuralPDE Julia

I am trying to run a model using the GPU, no problem with the CPU. I think somehow using measured boundary conditions is causing the issue but I am not sure. I am following this example: https://...
user1321988's user avatar
2 votes
1 answer
132 views

What is this syntax with a function from an empty tuple in Julia Flux gradient?

I can't find a reference documentation for the gradient function of Julia Flux, there are only several tutorial examples. I understand how gradient is used to compute gradients of functions, e.g. the ...
Yrogirg's user avatar
  • 2,321
3 votes
3 answers
381 views

Is there a way to print loss from Flux.train?

I'm trying to train a UNet in Julia with the help of Flux. Flux.train!(loss, Flux.params(model), train_data_loader, opt) batch_loss = loss(train_data, train_targets) where the loss is ...
h612's user avatar
  • 544
1 vote
0 answers
203 views

Error while using GPU on UNET with FLUX in Julia

I'm using Julia for UNet training with GPU. (Runs without issues on CPU). The error is at NNlib's function conv_im2col() function conv_im2col!( y::AbstractArray{T,5}, x::AbstractArray{...
h612's user avatar
  • 544
7 votes
1 answer
872 views

What is the purpose of [extras] and [targets] in a Julia Project.toml?

In the following example (code copied from the Flux project.toml) what is the purpose of the [extras] and [targets] sections? [compat] Adapt = "3.0" ArrayInterface = "3.1, 4, 5, 6" ...
vikram-s-narayan's user avatar
0 votes
1 answer
229 views

Installing Flux.jl on Linux: NNlibCUDA fails to precompile

While trying to install Flux I run into an error where it fails to precompile the NNlibCUDA library. Running ] test NNlibCUDA results in LoadError: UndefVarError: upsample_linear_wcn! not defined: (@...
Manuel Antoinette's user avatar
1 vote
1 answer
336 views

Error in the most simplest example in Flux.jl

I am testing the example here: https://fluxml.ai/Flux.jl/stable/models/overview/ using Flux actual(x) = 4x + 2 x_train, x_test= hcat(0:5...), hcat(6:10...) y_train, y_test = actual.(x_train), actual.(...
WinterInTheEast's user avatar
2 votes
1 answer
181 views

Linear combinations of Zygote.Grads

I am building and training a neural network model with Flux, and I am wondering if there is a way to take linear combinations of Zygote.Grads types. Here is a minimalistic example. This is how it is ...
5Pack's user avatar
  • 333
2 votes
2 answers
337 views

Custom Loss Function in Flux.jl

I am trying to implement a model with a custom loss function in the Flux.jl package. I include the code for a simplified model, but the error stays the same. I have an interpolator which takes a ...
Stefan Berger's user avatar
0 votes
1 answer
161 views

No decrease in loss after lots traning

I was trying to train a convolution network. But it is not improving, i.e. loss is not decreasing. And the train function is also terminating much more quickly than usual. Below is the minimal code to ...
Ritu Lahkar's user avatar
3 votes
2 answers
135 views

How to know which module exports a certain function

I was going through this Flux.jl tutorial and came across something called Chain. m = Chain(Dense(10, 5, relu), Dense(5, 2), softmax) It was not imported from any of the used modules and no namespace ...
Jafar Isbarov's user avatar
0 votes
1 answer
422 views

Flux.jl: How to sample random batch in dataloader?

I'm trying to randomly sample a mini-batch from Flux.dataloader rather than iterate through... I already created train_dataloader object, and all I need is random sampling from this object. Can you ...
Heesoo Song's user avatar
3 votes
2 answers
431 views

Flux.jl : Customizing optimizer

I'm trying to implement a gradient-free optimizer function to train convolutional neural networks with Julia using Flux.jl. The reference paper is this: https://arxiv.org/abs/2005.05955. This paper ...
Heesoo Song's user avatar
1 vote
0 answers
199 views

DimensionMisMatch Error Just Before Training

I’m trying to train a MLP model to predict number of real roots of polynomials. x_train and y_train include array of arrays such as [[-204, 20, 13, 1, 0]] which are coefficients of polynomials. x_test ...
skywalker's user avatar
6 votes
0 answers
560 views

I have a problem precompile the Flux package in Julia

I am trying to add Flux into my package repository in Julia but I am getting an error. I typed pkg> add Flux but Julia REPL returns "5 dependencies errored". And they are: LLVM ...
Kostas Fasoulakos's user avatar
1 vote
0 answers
59 views

why in julia Tracker.update!(W,-alpha*gW) and W = W - alpha * gW behaved differently?

I am very new to julia. While following tutorial in https://www.math.purdue.edu/~allen450/ML-with-Julia-Tutorial.html, Tracker.update!(W,-alpha*gW) and W = W - alpha * gW behaved differently. With W ...
Ritu Lahkar's user avatar
1 vote
1 answer
157 views

LoadError: MethodError while training LSTM model in Julia

I'm trying to train an LSTM model to predict number of real roots of polynomials. x_train and y_train include array of arrays such as [[-204, 20, 13, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
skywalker's user avatar
2 votes
1 answer
360 views

Unexpected difference in behaviour with/out let block

I have been using Flux.jl and have been confused by the differences when running code within a let block and without. The following example runs without error: using Flux p = rand(2) function f(x) ...
L.Grozinger's user avatar
  • 2,344
2 votes
0 answers
170 views

An unexpected variable reference changing during Julia Zygote gradient pullback

I'm using Julia Flux.jl to train models. But when I customize my model, there is an issue the variable reference in gradient pullback function doesn't behave as expected. For simplicity, the issue ...
IceQuarze's user avatar
2 votes
1 answer
288 views

How can I evaluate and take the derivative of a neural net in Julia

I have solved a differential equation with a neural net. I leave code below with an example. I want to be able to compute the first derivative of this neural net with respect to its input "x"...
Gooseeee's user avatar
1 vote
1 answer
239 views

Loading a Flux model into a MLJ machine

I would like to find out if it's possible to load a saved Flux model or its weights (a .bson file) into an MLJ machine. I would like to evaluate the performance of my model, using the Performance ...
Samuel Mbiya's user avatar
1 vote
2 answers
417 views

Do you have to write a custom training loop to get the loss value in each epoch with Flux.jl?

Flux.jl provides a helpful train! function which when paired with the @epoch macro, can serve as the main training loop. However, unlike most custom training loops, there is no output info as to the ...
logankilpatrick's user avatar
1 vote
1 answer
264 views

How to load an image for inference in Flux.jl?

I have a model which I trained using a specific dataset. I did not originally break the set up into a train and test set (which I should have). With that said, I want to do some adhoc testing to see ...
logankilpatrick's user avatar
1 vote
1 answer
256 views

Flux.jl model always outputs 1.0 after adding Sigmoid activation function

My original issue was that I wanted my model to only output 0-1 so I can map back to my categorical images labels (Flux.jl restrict variables between 0 and 1). So I decided to add a sigmoid activation ...
logankilpatrick's user avatar
3 votes
3 answers
462 views

How to check the input dimensions of a model in Flux.jl?

I have a resnet model which I am working with. I originally trained the model using batches of images. Now that it is trained, I want to do inference on a single image (224x224 with 3 color channels). ...
logankilpatrick's user avatar
0 votes
1 answer
144 views

Load an arbitrary .BSON file into Flux.jl which wasn't created using Flux

Right now, I am trying to load an arbitrary .BSON model into Flux which looks like the following: weights = ONNX.load_weights("weights.bson") Dict{String, Any} with 521 entries: "...
logankilpatrick's user avatar
2 votes
0 answers
208 views

Integrodifferential PDE with NeuralPDEs - Julia

I am trying to numerically solve an integrodifferential PDE with NeuralPDE.jl. The equation has an analytical solution in the Laplace domain, and therefore I can validate the numerical solution. The ...
dapias's user avatar
  • 2,522
1 vote
0 answers
208 views

Training NN with Julia's Flux - Loss function with derivative of output and functions of output

I want to run this NN in which input is time over some interval. There's no label, and the loss function requires the derivative of the outputs and a specified function (H in my code), which is also a ...
Gabriel RM's user avatar
2 votes
1 answer
404 views

How to use a .pth model in Flux.jl?

I have a model trained in PyTorch, saved in .pth format. Is it possible to use and load that model in Flux.jl? I looked around but did not see this mentioned anywhere in the Flux docs.
logankilpatrick's user avatar
2 votes
1 answer
241 views

Multi label classification in Flux.jl?

I am currently working with a dataset in which the boundary between classes is not very well defined. I don't want to use regular classification since the nuance overlap of these classes might not be ...
logankilpatrick's user avatar
1 vote
1 answer
244 views

How to freeze layer parameters in Flux.jl

I am currently working on a transfer learning problem so I would like to freeze most of my layers such that the model is not re-trained, and only the final layer's weights are modified. How can I ...
logankilpatrick's user avatar
1 vote
0 answers
342 views

How to make use LSTM's in Flux.jl?

I am currently working with some Video data so rather than use a standard feed-forward model, I want to use a Long short-term memory (LSTM) architecture such that the context/memory persists in the ...
logankilpatrick's user avatar
0 votes
0 answers
318 views

How to implement dropout in Flux.jl?

My current model is suffering from overfitting. I want to be able to add dropout to my model such that I prevent overfitting by shutting down some neurons. I was reading through this article on ...
logankilpatrick's user avatar