# Machine Learning

**URL:** https://discourse.julialang.org/c/domain/ml/24.md?page=18

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 19

---

## [Zygote gradient error with \`reduce\` on GPU](https://discourse.julialang.org/t/zygote-gradient-error-with-reduce-on-gpu/94049)

<div class="topic-metadata">

**Author:** [@ogoid](https://discourse.julialang.org/u/ogoid)\
**Replies:** 3\
**Last updated:** [February 6, 2023, 12:15am UTC](https://discourse.julialang.org/t/zygote-gradient-error-with-reduce-on-gpu/94049 "2023-02-06T00:15:03Z")

</div>

Hello, I’m trying to use reduce (and mapreduce and its variants) in the loss function of a Flux neural network, but Zygote throws an error when it runs on the GPU (works fine on the CPU though). Are these functions unsu…

---

## [MLJ: RootMeanSquaredLogError() returns Inf instead of actual score](https://discourse.julialang.org/t/mlj-rootmeansquaredlogerror-returns-inf-instead-of-actual-score/93995)

<div class="topic-metadata">

**Author:** [@clouedoc](https://discourse.julialang.org/u/clouedoc)\
**Replies:** 0\
**Last updated:** [February 3, 2023, 3:25pm UTC](https://discourse.julialang.org/t/mlj-rootmeansquaredlogerror-returns-inf-instead-of-actual-score/93995 "2023-02-03T15:25:20Z")

</div>

Hello, I’m trying to build a model for the Store Sales Kaggle Competition. I’ve tried to build a super-simple model that only takes two-three features and submit my predictions to Kaggle. The numbers didn’t correspond …

---

## [Automatic gradient ∼10x slower to evaluate than the primal computation](https://discourse.julialang.org/t/automatic-gradient-10x-slower-to-evaluate-than-the-primal-computation/93925)

<div class="topic-metadata">

**Author:** [@user22](https://discourse.julialang.org/u/user22)\
**Replies:** 2\
**Last updated:** [February 3, 2023, 6:15am UTC](https://discourse.julialang.org/t/automatic-gradient-10x-slower-to-evaluate-than-the-primal-computation/93925 "2023-02-03T06:15:44Z")

</div>

I need to evaluate a basic dense and a few-layer neural network with up to tens of thousands of inputs at once. The outputs will be then forwarded to another function, which returns a scalar. However, the performance of …

---

## [Elegant way to handle multiple input flux layers?](https://discourse.julialang.org/t/elegant-way-to-handle-multiple-input-flux-layers/93913)

<div class="topic-metadata">

**Author:** [@reachtarunhere](https://discourse.julialang.org/u/reachtarunhere)\
**Replies:** 4\
**Last updated:** [February 2, 2023, 5:50pm UTC](https://discourse.julialang.org/t/elegant-way-to-handle-multiple-input-flux-layers/93913 "2023-02-02T17:50:47Z")

</div>

The issue I am pointing at arrives when implementing encoder for transformer models with masking. Below I have tried to do a fake minimal example instead. We have a custom layer which takes a couple of inputs. For a tra…

---

## [Why the Loss function does not decrease significantly in Flux.jl](https://discourse.julialang.org/t/why-the-loss-function-does-not-decrease-significantly-in-flux-jl/93918)

<div class="topic-metadata">

**Author:** [@quantiota](https://discourse.julialang.org/u/quantiota)\
**Replies:** 2\
**Last updated:** [February 2, 2023, 4:50pm UTC](https://discourse.julialang.org/t/why-the-loss-function-does-not-decrease-significantly-in-flux-jl/93918 "2023-02-02T16:50:00Z")

</div>

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{Float64}(rand(5, 100…

---

## [Integrating MLUtils.DataLoader and image augmentation pipeline on custom dataset](https://discourse.julialang.org/t/integrating-mlutils-dataloader-and-image-augmentation-pipeline-on-custom-dataset/93887)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 5\
**Last updated:** [February 2, 2023, 7:05am UTC](https://discourse.julialang.org/t/integrating-mlutils-dataloader-and-image-augmentation-pipeline-on-custom-dataset/93887 "2023-02-02T07:05:08Z")

</div>

Hi, I’m trying to create a custom dataset where getobs performs random image augmentations. The DataLoader docs suggest that my dataset has to have custom numobs and getobs calls. So this is my code: struct my\_datase…

---

## [Can not run simple example with LIBSVM](https://discourse.julialang.org/t/can-not-run-simple-example-with-libsvm/93875)

<div class="topic-metadata">

**Author:** [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Replies:** 4\
**Last updated:** [February 1, 2023, 7:24pm UTC](https://discourse.julialang.org/t/can-not-run-simple-example-with-libsvm/93875 "2023-02-01T19:24:53Z")

</div>

I am trying to run this code: using LIBSVM x = randn(20, 2) labels = repeat(\[-1,1\], 10) model = svmtrain(x', labels) I tried to run it in JupyterLab, VSCode and REPL but it gives me a definitive error (the kernel di…

---

## [How to add sleep to "JuliaRL\_BasicDQN\_CartPole"?](https://discourse.julialang.org/t/how-to-add-sleep-to-juliarl-basicdqn-cartpole/93810)

<div class="topic-metadata">

**Author:** [@MikeB](https://discourse.julialang.org/u/MikeB)\
**Replies:** 7\
**Last updated:** [February 1, 2023, 9:08am UTC](https://discourse.julialang.org/t/how-to-add-sleep-to-juliarl-basicdqn-cartpole/93810 "2023-02-01T09:08:17Z")

</div>

I’m trying to use the above-named ReinforcementLearning.jl experiment to model training a DQN that calls out to another program and introduces some lag time. I can, of course, run the experiment but I can’t quite figure …

---

## [Changing RL Experiment Arguments](https://discourse.julialang.org/t/changing-rl-experiment-arguments/93856)

<div class="topic-metadata">

**Author:** [@MikeB](https://discourse.julialang.org/u/MikeB)\
**Replies:** 1\
**Last updated:** [February 1, 2023, 9:06am UTC](https://discourse.julialang.org/t/changing-rl-experiment-arguments/93856 "2023-02-01T09:06:52Z")

</div>

This is kind of embarrassing, but, I can’t figure out how to change the seed=123 argument on the DQN\_Cartpole experiment. I threw the code into a Jupyter notebook, with the function in one big cell, then the ex=E'JuliaR…

---

## [Constrain weights and biases to be positive](https://discourse.julialang.org/t/constrain-weights-and-biases-to-be-positive/93381)

<div class="topic-metadata">

**Author:** [@marco\_menarini](https://discourse.julialang.org/u/marco_menarini)\
**Replies:** 5\
**Last updated:** [January 30, 2023, 8:38am UTC](https://discourse.julialang.org/t/constrain-weights-and-biases-to-be-positive/93381 "2023-01-30T08:38:02Z")

</div>

Is it possible to use a custom constrained optimizer or to modify the gradients to only allow for positive weights and biases?

---

## [⸘How do I do "tensor slicing" in Flux and CUDA‽](https://discourse.julialang.org/t/how-do-i-do-tensor-slicing-in-flux-and-cuda/93590)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 5\
**Last updated:** [January 30, 2023, 3:47am UTC](https://discourse.julialang.org/t/how-do-i-do-tensor-slicing-in-flux-and-cuda/93590 "2023-01-30T03:47:02Z")

</div>

If I have a tensor T ∈ ∏ ℝⁱₖ|k ∈ {1,…,m} and I want to drop some elements to get T̂ ∈ ∏ ℝⁿₖ|k ∈ {1,…,m}, nₖ = iₖ | k ∈ {1,…,m}\\{p| p ∈ ℕ, 1 ≤ p ≤ m} ∧ 1 ≤ nₖ ≤ iₖ | k = p, how should I then include that transformation in…

---

## [Flux How to convert model weights to Float16](https://discourse.julialang.org/t/flux-how-to-convert-model-weights-to-float16/93630)

<div class="topic-metadata">

**Author:** [@reachtarunhere](https://discourse.julialang.org/u/reachtarunhere)\
**Replies:** 2\
**Last updated:** [January 27, 2023, 2:01pm UTC](https://discourse.julialang.org/t/flux-how-to-convert-model-weights-to-float16/93630 "2023-01-27T14:01:54Z")

</div>

m = Dense(10, 2) # now the initialized weights are Float32 type. m2 = Dense(rand(Float16, 2, 10)) # works When I init the weights it is fine but I have an existing complex model with many layers and I would like Float1…

---

## [Zygote error in backprop through NN](https://discourse.julialang.org/t/zygote-error-in-backprop-through-nn/92920)

<div class="topic-metadata">

**Author:** [@LucasMSpereira](https://discourse.julialang.org/u/LucasMSpereira)\
**Replies:** 4\
**Last updated:** [January 21, 2023, 1:54am UTC](https://discourse.julialang.org/t/zygote-error-in-backprop-through-nn/92920 "2023-01-21T01:54:27Z")

</div>

Following my last post about implementing WGAN-GP, now I’m running into another problem with gradients. Changing the discriminator’s BatchNorm() to Metalhead’s ChannelLayerNorm() solves the issue with the inner gradient.…

---

## [My model can't be transfered to gpu. Adapt.jl problem?](https://discourse.julialang.org/t/my-model-cant-be-transfered-to-gpu-adapt-jl-problem/92585)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 12\
**Last updated:** [January 21, 2023, 1:45am UTC](https://discourse.julialang.org/t/my-model-cant-be-transfered-to-gpu-adapt-jl-problem/92585 "2023-01-21T01:45:00Z")

</div>

I have a model I’ve been working with and when I’m trying to expand it to work with arbitrary numbers of channels (some of which can be switched off) transfer to gpu keeps choking on the line: sparams = ntuple(i-\>F.para…

---

## [Flux + Automatic Differentiation](https://discourse.julialang.org/t/flux-automatic-differentiation/93224)

<div class="topic-metadata">

**Author:** [@parf](https://discourse.julialang.org/u/parf)\
**Replies:** 3\
**Last updated:** [January 19, 2023, 6:04pm UTC](https://discourse.julialang.org/t/flux-automatic-differentiation/93224 "2023-01-19T18:04:45Z")

</div>

Hi! I am trying to construct PINN to solve 1D Burgers equation in Flux.jl without using NeuralPDE.jl. The velocity field u(t,x) is defined by the neural net and I have to calculate the gradients with respect to t and x i…

---

## [How to profile Zygote gradients](https://discourse.julialang.org/t/how-to-profile-zygote-gradients/90398)

<div class="topic-metadata">

**Author:** [@renatobellotti](https://discourse.julialang.org/u/renatobellotti)\
**Replies:** 2\
**Last updated:** [January 19, 2023, 3:43pm UTC](https://discourse.julialang.org/t/how-to-profile-zygote-gradients/90398 "2023-01-19T15:43:46Z")

</div>

Hi, I’m currently running an expensive optimisation with a code that uses Zygote for automatic differentiation. The gradient computation seems to dominate the computational cost. Is it possible to profile which parts of…

---

## [How to format sequential data to be used in reccurence models when batches are needed?](https://discourse.julialang.org/t/how-to-format-sequential-data-to-be-used-in-reccurence-models-when-batches-are-needed/93060)

<div class="topic-metadata">

**Author:** [@mantzaris](https://discourse.julialang.org/u/mantzaris)\
**Replies:** 6\
**Last updated:** [January 18, 2023, 2:23am UTC](https://discourse.julialang.org/t/how-to-format-sequential-data-to-be-used-in-reccurence-models-when-batches-are-needed/93060 "2023-01-18T02:23:40Z")

</div>

What is the best (recommended) way to store sequence data for recurrence models in Flux when it is aimed to be used in ‘batches’? At the moment I store the X data (features) as onehot hot encoded where the features span …

---

## [How to use data for training and tests with glm?](https://discourse.julialang.org/t/how-to-use-data-for-training-and-tests-with-glm/92928)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 5\
**Last updated:** [January 13, 2023, 5:07pm UTC](https://discourse.julialang.org/t/how-to-use-data-for-training-and-tests-with-glm/92928 "2023-01-13T17:07:07Z")

</div>

Hello, good morning. I’m having troubles to separate and use my data for training and tests with glm. Once I have tests and training data, I had fit my model with train data, but can’t understand how to predic with my t…

---

## [How to capture model output with loss in Flux.withgradient](https://discourse.julialang.org/t/how-to-capture-model-output-with-loss-in-flux-withgradient/92766)

<div class="topic-metadata">

**Author:** [@reachtarunhere](https://discourse.julialang.org/u/reachtarunhere)\
**Replies:** 3\
**Last updated:** [January 13, 2023, 2:54pm UTC](https://discourse.julialang.org/t/how-to-capture-model-output-with-loss-in-flux-withgradient/92766 "2023-01-13T14:54:59Z")

</div>

Here is the sample code for my training loop function train() @showprogress for i in 1:10 l, grads = Flux.withgradient(m -\> lossfn(m(X), Y), model) fmap(model, grads\[1\]) do p, g p .= p .-…

---

## [Machine Learning Classification](https://discourse.julialang.org/t/machine-learning-classification/92915)

<div class="topic-metadata">

**Author:** [@BadBoy](https://discourse.julialang.org/u/BadBoy)\
**Replies:** 3\
**Last updated:** [January 13, 2023, 1:41pm UTC](https://discourse.julialang.org/t/machine-learning-classification/92915 "2023-01-13T13:41:27Z")

</div>

How can I find the best subset of the predictors for a classification problem?? Any kind of help will be appreciated. Thanks in advance.

---

## [Hyperopt.jl Hyperband states existing variables are undefined](https://discourse.julialang.org/t/hyperopt-jl-hyperband-states-existing-variables-are-undefined/92740)

<div class="topic-metadata">

**Author:** [@RLB](https://discourse.julialang.org/u/RLB)\
**Replies:** 0\
**Last updated:** [January 10, 2023, 1:30am UTC](https://discourse.julialang.org/t/hyperopt-jl-hyperband-states-existing-variables-are-undefined/92740 "2023-01-10T01:30:37Z")

</div>

Package Versions: Julia - v1.8.3 Flux - v0.13.9 Hyperopt - v0.5.6 I’m attempting to use the Hyperopt.jl package to help tune the layers and number of nodes in a neural network. I would like to be able to use their im…

---

## [How to implement custom image dataset for cnn in Julia Flux?](https://discourse.julialang.org/t/how-to-implement-custom-image-dataset-for-cnn-in-julia-flux/92505)

<div class="topic-metadata">

**Author:** [@Hardik\_Sakpal](https://discourse.julialang.org/u/Hardik_Sakpal)\
**Replies:** 6\
**Last updated:** [January 9, 2023, 7:00pm UTC](https://discourse.julialang.org/t/how-to-implement-custom-image-dataset-for-cnn-in-julia-flux/92505 "2023-01-09T19:00:00Z")

</div>

Hello, I want to train a CNN model using Julia Flux but I am not able to load and preprocess the custom image dataset for training. Can anyone provide me the code snippet for loading the custom image dataset and preproc…

---

## [MethodError: no method matching Float32(::RGB{N0f8})](https://discourse.julialang.org/t/methoderror-no-method-matching-float32-rgb-n0f8/92701)

<div class="topic-metadata">

**Author:** [@Hardik\_Sakpal](https://discourse.julialang.org/u/Hardik_Sakpal)\
**Replies:** 4\
**Last updated:** [January 9, 2023, 10:56am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-float32-rgb-n0f8/92701 "2023-01-09T10:56:43Z")

</div>

Hello All, I am trying to do CNN Classification using Julia Flux but while doing so in one of the codes I am getting above mentioned error. using Flux using FileIO using Plots using Images using MLDataUtils: splitobs, …

---

## [MLJ w/Scikitlearn: passing return\_std to predict](https://discourse.julialang.org/t/mlj-w-scikitlearn-passing-return-std-to-predict/91654)

<div class="topic-metadata">

**Author:** [@evolbio](https://discourse.julialang.org/u/evolbio)\
**Replies:** 7\
**Last updated:** [January 9, 2023, 1:33am UTC](https://discourse.julialang.org/t/mlj-w-scikitlearn-passing-return-std-to-predict/91654 "2023-01-09T01:33:26Z")

</div>

Various Scikitlearn models accept return\_std=true when calling predict, for example BayesianRidgeRegressor, see this example. For example, with a BayesianRidgeRegressor or similar machine, I would like to call y\_predict…

---

## [Compilation error in Zygote, Flux and CUDA interaction](https://discourse.julialang.org/t/compilation-error-in-zygote-flux-and-cuda-interaction/92571)

<div class="topic-metadata">

**Author:** [@LucasMSpereira](https://discourse.julialang.org/u/LucasMSpereira)\
**Replies:** 3\
**Last updated:** [January 6, 2023, 11:25pm UTC](https://discourse.julialang.org/t/compilation-error-in-zygote-flux-and-cuda-interaction/92571 "2023-01-06T23:25:32Z")

</div>

I’m trying to implement a conditioned adaptation of the wasserstein generative adversarial networks with gradient penalty (WGAN-GP) training algorithm. But my function to calculate the gradient penalty isn’t working on t…

---

## [Zygote InexactError using repeat() with inner keyword](https://discourse.julialang.org/t/zygote-inexacterror-using-repeat-with-inner-keyword/92600)

<div class="topic-metadata">

**Author:** [@phK3](https://discourse.julialang.org/u/phK3)\
**Replies:** 3\
**Last updated:** [January 6, 2023, 3:01pm UTC](https://discourse.julialang.org/t/zygote-inexacterror-using-repeat-with-inner-keyword/92600 "2023-01-06T15:01:51Z")

</div>

The following function throws InexactError: Int64(2.0794415416798357): function get\_error(G, E, x) n, m = size(G) Ê = repeat(E, inner=(1, m)) Ĝ = repeat(G, inner=(1, m)) return Ĝ \* prod(x.^Ê, dims=1)…

---

## [Julia PINN converged but bcs are not fulfilled](https://discourse.julialang.org/t/julia-pinn-converged-but-bcs-are-not-fulfilled/92351)

<div class="topic-metadata">

**Author:** [@c\_sell](https://discourse.julialang.org/u/c_sell)\
**Replies:** 4\
**Last updated:** [January 3, 2023, 7:12pm UTC](https://discourse.julialang.org/t/julia-pinn-converged-but-bcs-are-not-fulfilled/92351 "2023-01-03T19:12:37Z")

</div>

Hi everyone, I am trying to solve a PDE with the julia package Neural.jl. I have 3 bcs. At two boundarys the pressure has to be zero. The last bsc ist a periodic boundary condition. The pressure at the one side has to …

---

## [Data normalization with NaN values in StatsBase](https://discourse.julialang.org/t/data-normalization-with-nan-values-in-statsbase/92429)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.julialang.org/u/Jack)\
**Replies:** 1\
**Last updated:** [January 2, 2023, 10:51pm UTC](https://discourse.julialang.org/t/data-normalization-with-nan-values-in-statsbase/92429 "2023-01-02T22:51:35Z")

</div>

Greetings, I have been trying to do some basic normalization with ZScore transform like in this StatsBase package, and found that the package wouldn’t handle NaN values properly. For example Random.seed!(1234) input =…

---

## [Minibatching with FFJORD](https://discourse.julialang.org/t/minibatching-with-ffjord/92210)

<div class="topic-metadata">

**Author:** [@kaido975](https://discourse.julialang.org/u/kaido975)\
**Replies:** 1\
**Last updated:** [December 28, 2022, 1:35pm UTC](https://discourse.julialang.org/t/minibatching-with-ffjord/92210 "2022-12-28T13:35:50Z")

</div>

I am trying to implement the code given in Continuous Normalizing Flows · DiffEqFlux.jl, with mini batching. using Flux, DiffEqFlux, DifferentialEquations, Optimization, OptimizationFlux, OptimizationOptimJL, Dist…

---

## [Idea to make Zygote support mutation in easy cases](https://discourse.julialang.org/t/idea-to-make-zygote-support-mutation-in-easy-cases/92118)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 6\
**Last updated:** [December 27, 2022, 4:34pm UTC](https://discourse.julialang.org/t/idea-to-make-zygote-support-mutation-in-easy-cases/92118 "2022-12-27T16:34:21Z")

</div>

Motivation The appeal of automatic differentiation is that you can write a function using ordinary Julia and the gradient is automatically computed. Disallowing mutation in that function seems reasonable on the surface—i…

[Previous page](https://discourse.julialang.org/c/domain/ml/24.md?page=17)

[Next page](https://discourse.julialang.org/c/domain/ml/24.md?page=19)
