# Machine Learning

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

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

**Page:** 41

---

## [MLJ confusion\_matrix() - MethodError](https://discourse.julialang.org/t/mlj-confusion-matrix-methoderror/46856)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 5\
**Last updated:** [September 18, 2020, 7:39pm UTC](https://discourse.julialang.org/t/mlj-confusion-matrix-methoderror/46856 "2020-09-18T19:39:33Z")

</div>

I am trying to make a RF predictor of a categorical variable (3 levels), and then look at how well the model works. I mostly followed the steps in the Getting Started section of the docs - here’s a MWE: using DataFrames…

---

## [Flux: concatenate layers](https://discourse.julialang.org/t/flux-concatenate-layers/18877)

<div class="topic-metadata">

**Author:** [@zot](https://discourse.julialang.org/u/zot)\
**Replies:** 7\
**Last updated:** [September 18, 2020, 11:13am UTC](https://discourse.julialang.org/t/flux-concatenate-layers/18877 "2020-09-18T11:13:45Z")

</div>

I’m looking for a way to concatenate layers in Flux like this: Would this work for that? The input is an array of inputs to the layers and the output is the concatenation of the layers’ outputs. Creating it would be …

---

## [Flux.params does not recognize parameters with \`x -\> layer(x)\` syntax](https://discourse.julialang.org/t/flux-params-does-not-recognize-parameters-with-x-layer-x-syntax/46832)

<div class="topic-metadata">

**Author:** [@tgrassi](https://discourse.julialang.org/u/tgrassi)\
**Replies:** 4\
**Last updated:** [September 18, 2020, 11:10am UTC](https://discourse.julialang.org/t/flux-params-does-not-recognize-parameters-with-x-layer-x-syntax/46832 "2020-09-18T11:10:26Z")

</div>

Hi all, I have a basic question about params in Flux that confuses me. Why do I get different parameters in these two cases? Shouldn’t be equivalent? using Flux m1 = x -\> Dense(4, 2)(x) println(params(m1)) m2 = Dens…

---

## [Package similar to Ludwig](https://discourse.julialang.org/t/package-similar-to-ludwig/46731)

<div class="topic-metadata">

**Author:** [@ludovic\_chauveau](https://discourse.julialang.org/u/ludovic_chauveau)\
**Replies:** 0\
**Last updated:** [September 16, 2020, 9:08pm UTC](https://discourse.julialang.org/t/package-similar-to-ludwig/46731 "2020-09-16T21:08:44Z")

</div>

Hi peeps, From long time ago I things do a solution to easily use ML & Deep Learning with Julia but I’m a newby in this domain. So I make research of No-Code / Low-Code AI / ML… I just found an existing open source pro…

---

## [ANN: Knet 1.4.0: accelerating CuArrays](https://discourse.julialang.org/t/ann-knet-1-4-0-accelerating-cuarrays/45206)

<div class="topic-metadata">

**Author:** [@denizyuret](https://discourse.julialang.org/u/denizyuret)\
**Replies:** 26\
**Last updated:** [September 15, 2020, 4:15pm UTC](https://discourse.julialang.org/t/ann-knet-1-4-0-accelerating-cuarrays/45206 "2020-09-15T16:15:57Z")

</div>

I just released Knet 1.4.0, a major refactoring of the code (lots of submodules) for future improvements without any current API effects (hopefully). My first goal for this release was to fully support CuArrays without …

---

## [Zygote unexpected broadcasting](https://discourse.julialang.org/t/zygote-unexpected-broadcasting/46476)

<div class="topic-metadata">

**Author:** [@merckxiaan](https://discourse.julialang.org/u/merckxiaan)\
**Replies:** 1\
**Last updated:** [September 15, 2020, 9:47am UTC](https://discourse.julialang.org/t/zygote-unexpected-broadcasting/46476 "2020-09-15T09:47:48Z")

</div>

This is a MWE for a problem i’m having, I’ve adapted matrix multiplication to accept trans arguments telling whether the matrix is to be transposed. As for the adjoint definition, I looked at NNlib.batched\_mul When I t…

---

## [Adjointing around Mutating Part](https://discourse.julialang.org/t/adjointing-around-mutating-part/46582)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 0\
**Last updated:** [September 14, 2020, 11:42am UTC](https://discourse.julialang.org/t/adjointing-around-mutating-part/46582 "2020-09-14T11:42:38Z")

</div>

I have the following toy problem that imitates my more complex problem. (A follow up from this question.) function triangulate(x::Matrix{T}) where T m, n = size(x) a = x\[:,1\] .\* \[1; zeros(T, m-1)\] for i in 2…

---

## [Broadcasting in loss function for RNN with timeseries](https://discourse.julialang.org/t/broadcasting-in-loss-function-for-rnn-with-timeseries/44526)

<div class="topic-metadata">

**Author:** [@raoulg](https://discourse.julialang.org/u/raoulg)\
**Replies:** 4\
**Last updated:** [September 12, 2020, 10:33pm UTC](https://discourse.julialang.org/t/broadcasting-in-loss-function-for-rnn-with-timeseries/44526 "2020-09-12T22:33:55Z")

</div>

I’m trying to get an RNN to work with timeseries and I don’t understand why things don’t work as expected. I found a workaround, but it just seems to be too complicated. My data are sequences of 29 observations, and I h…

---

## [Impose initialization adn normalization on layers in Flux](https://discourse.julialang.org/t/impose-initialization-adn-normalization-on-layers-in-flux/23921)

<div class="topic-metadata">

**Author:** [@stefesse](https://discourse.julialang.org/u/stefesse)\
**Replies:** 2\
**Last updated:** [September 11, 2020, 8:48pm UTC](https://discourse.julialang.org/t/impose-initialization-adn-normalization-on-layers-in-flux/23921 "2020-09-11T20:48:35Z")

</div>

Hi all, I am constructing a simple perceptron with Flux, something like: y = W\*x + b. To do so I simply use: model = Dense(N,1,nonlinearity); What I do not understand is: How can I impose the initial value for the ma…

---

## [Neural ODE fitting really slow](https://discourse.julialang.org/t/neural-ode-fitting-really-slow/45516)

<div class="topic-metadata">

**Author:** [@vaglino](https://discourse.julialang.org/u/vaglino)\
**Replies:** 13\
**Last updated:** [September 11, 2020, 6:55pm UTC](https://discourse.julialang.org/t/neural-ode-fitting-really-slow/45516 "2020-09-11T18:55:32Z")

</div>

I’m trying to fit this simple neural ODE, first with adam then bfgs, but the performance is extremely slow (about 15 minutes for 100 adams iterations). I am basing the code on the SciML talk from JuliaCon 2020. When I ti…

---

## [Training a simple linear model in Flux](https://discourse.julialang.org/t/training-a-simple-linear-model-in-flux/24741)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 4\
**Last updated:** [September 11, 2020, 3:20pm UTC](https://discourse.julialang.org/t/training-a-simple-linear-model-in-flux/24741 "2020-09-11T15:20:10Z")

</div>

I’m trying to get started with Flux, but finding the documentation a bit lacking in regards to explaining the basic functionality. For example, how would I train the following linear model with a single scalar parameter…

---

## [Gradients from an SDE solver with callbacks](https://discourse.julialang.org/t/gradients-from-an-sde-solver-with-callbacks/46317)

<div class="topic-metadata">

**Author:** [@MikeKlocCZ](https://discourse.julialang.org/u/MikeKlocCZ)\
**Replies:** 2\
**Last updated:** [September 11, 2020, 7:49am UTC](https://discourse.julialang.org/t/gradients-from-an-sde-solver-with-callbacks/46317 "2020-09-11T07:49:03Z")

</div>

I am trying to get gradients of the solution of an SDE where a callback function is used in the solve command. It seems that the forward adjoint method is not compatible with the usage of callbacks as I get "ERROR: type…

---

## [How do I implement the Parametric ReLU (PReLU) function in Flux v0.11.1?](https://discourse.julialang.org/t/how-do-i-implement-the-parametric-relu-prelu-function-in-flux-v0-11-1/46310)

<div class="topic-metadata">

**Author:** [@RiN](https://discourse.julialang.org/u/RiN)\
**Replies:** 5\
**Last updated:** [September 10, 2020, 1:05pm UTC](https://discourse.julialang.org/t/how-do-i-implement-the-parametric-relu-prelu-function-in-flux-v0-11-1/46310 "2020-09-10T13:05:59Z")

</div>

I want to handle the Parametric ReLU (PReLU) function in Flux v0.11.1. https://arxiv.org/abs/1502.01852 I’m trying to implement it in Flux based on the following post, but the version of Flux in this post is old and ma…

---

## [\[ANN\] Announcing Flux3D.jl, 3D Vision library](https://discourse.julialang.org/t/ann-announcing-flux3d-jl-3d-vision-library/46258)

<div class="topic-metadata">

**Author:** [@Nirmal\_Suthar](https://discourse.julialang.org/u/Nirmal_Suthar)\
**Replies:** 0\
**Last updated:** [September 8, 2020, 12:09pm UTC](https://discourse.julialang.org/t/ann-announcing-flux3d-jl-3d-vision-library/46258 "2020-09-08T12:09:25Z")

</div>

Dear Julia Community, I am really excited to share Flux3D.jl with all. It is a 3D vision library, written completely in Julia. This package utilizes Flux.jl and Zygote.jl as its building blocks for training 3D vision mo…

---

## [Flux: multiple input of unequal dimensions](https://discourse.julialang.org/t/flux-multiple-input-of-unequal-dimensions/46094)

<div class="topic-metadata">

**Author:** [@johnbb](https://discourse.julialang.org/u/johnbb)\
**Replies:** 4\
**Last updated:** [September 7, 2020, 8:52am UTC](https://discourse.julialang.org/t/flux-multiple-input-of-unequal-dimensions/46094 "2020-09-07T08:52:29Z")

</div>

Assume I have data as follows n = 1000 y = rand(n) x1 = rand(10, n) x2 = rand(20,20,1,n) and would like to a apply one (or more) Conv layers to x2 before it is flattened and concatenated with x1 in a Dense layer. How…

---

## [\`Conv\` is 2x slow than pytorch \`Conv\` on cpu](https://discourse.julialang.org/t/conv-is-2x-slow-than-pytorch-conv-on-cpu/39802)

<div class="topic-metadata">

**Author:** [@yiyuezhuo](https://discourse.julialang.org/u/yiyuezhuo)\
**Replies:** 9\
**Last updated:** [September 6, 2020, 5:43am UTC](https://discourse.julialang.org/t/conv-is-2x-slow-than-pytorch-conv-on-cpu/39802 "2020-09-06T05:43:34Z")

</div>

Example: using BenchmarkTools using Flux conv = Conv((7,7), 3 =\> 64; stride=2, pad=3) dummy = randn(Float32, 224, 224, 3, 2); conv(dummy) # ignore compile time @benchmark conv(dummy) #= BenchmarkTools.Trial: memor…

---

## [Regression Random Forests: Mean coeff of determination in cross-validation surprisingly too good for pure noise inputs](https://discourse.julialang.org/t/regression-random-forests-mean-coeff-of-determination-in-cross-validation-surprisingly-too-good-for-pure-noise-inputs/46073)

<div class="topic-metadata">

**Author:** [@rio](https://discourse.julialang.org/u/rio)\
**Replies:** 1\
**Last updated:** [September 4, 2020, 11:26pm UTC](https://discourse.julialang.org/t/regression-random-forests-mean-coeff-of-determination-in-cross-validation-surprisingly-too-good-for-pure-noise-inputs/46073 "2020-09-04T23:26:46Z")

</div>

I fitted a regression RF model on random (low dimensional) noise data and got surprising good estimates of the Mean Coeff of Determination using Cross-Validation. Here is my code, based on the example in https://github.…

---

## [Using LSTM with Conv layers](https://discourse.julialang.org/t/using-lstm-with-conv-layers/46007)

<div class="topic-metadata">

**Author:** [@nantonel](https://discourse.julialang.org/u/nantonel)\
**Replies:** 0\
**Last updated:** [September 3, 2020, 1:32pm UTC](https://discourse.julialang.org/t/using-lstm-with-conv-layers/46007 "2020-09-03T13:32:16Z")

</div>

I was wondering what is the best practice to use a LSTM (or any RNN) together with some convolutional layers using Flux and in general how to unite recurrent networks with other blocks. Say I have this simple problem wh…

---

## [How to make a Custom Layer work on GPU?](https://discourse.julialang.org/t/how-to-make-a-custom-layer-work-on-gpu/45836)

<div class="topic-metadata">

**Author:** [@pineapplehunter](https://discourse.julialang.org/u/pineapplehunter)\
**Replies:** 3\
**Last updated:** [September 2, 2020, 11:57am UTC](https://discourse.julialang.org/t/how-to-make-a-custom-layer-work-on-gpu/45836 "2020-09-02T11:57:02Z")

</div>

Hi. I’m trying to implement a funnel activation(FReLU) like this github for fun. https://github.com/megvii-model/FunnelAct An Pytorch implementation looks like this. import torch import torch.nn as nn class FReLU(nn.M…

---

## [Flux and cpu cores](https://discourse.julialang.org/t/flux-and-cpu-cores/45318)

<div class="topic-metadata">

**Author:** [@johnbb](https://discourse.julialang.org/u/johnbb)\
**Replies:** 6\
**Last updated:** [September 1, 2020, 9:29am UTC](https://discourse.julialang.org/t/flux-and-cpu-cores/45318 "2020-09-01T09:29:57Z")

</div>

When I run the following code using Flux n = 100\_000 p = 50 x = rand(Float32, p, n) y = rand(Float32, n) trdata = Flux.Data.DataLoader(x, y, batchsize=100) m = Chain(Dense(p, 100), Dense(100,100), Dense(100,1)) loss…

---

## [How to create a loss function with 3 inputs in Flux?](https://discourse.julialang.org/t/how-to-create-a-loss-function-with-3-inputs-in-flux/45755)

<div class="topic-metadata">

**Author:** [@DeepQ](https://discourse.julialang.org/u/DeepQ)\
**Replies:** 2\
**Last updated:** [August 30, 2020, 3:51am UTC](https://discourse.julialang.org/t/how-to-create-a-loss-function-with-3-inputs-in-flux/45755 "2020-08-30T03:51:26Z")

</div>

How could I create a loss function with 3 inputs like loss(w,x,y)? Could someone show me an example?

---

## [Why does Zygote produce a wrong derivative?](https://discourse.julialang.org/t/why-does-zygote-produce-a-wrong-derivative/45724)

<div class="topic-metadata">

**Author:** [@joachimbrand1](https://discourse.julialang.org/u/joachimbrand1)\
**Replies:** 5\
**Last updated:** [August 29, 2020, 9:06am UTC](https://discourse.julialang.org/t/why-does-zygote-produce-a-wrong-derivative/45724 "2020-08-29T09:06:32Z")

</div>

Trying to get my head around AD in Julia and being inspired by Jarret Revels’ example of computing the Jacobian of a cumprod() function with ForwardDiff.jl, I tried to see whether I could get the same done with Zygote.…

---

## [How to combine two layers?](https://discourse.julialang.org/t/how-to-combine-two-layers/45635)

<div class="topic-metadata">

**Author:** [@natema](https://discourse.julialang.org/u/natema)\
**Replies:** 1\
**Last updated:** [August 27, 2020, 10:06pm UTC](https://discourse.julialang.org/t/how-to-combine-two-layers/45635 "2020-08-27T22:06:48Z")

</div>

Let’s say we have trained a model m1 m1 = Chain(Dense(10, 10, relu), Dense(10,2), softmax) and we have then substituted Dense(10,2) with Dense(10,4) and trained the latter layer only, getting a model m2 m2 = Chain(Den…

---

## [Taking zygote gradient on function with ! operator fails on gpu](https://discourse.julialang.org/t/taking-zygote-gradient-on-function-with-operator-fails-on-gpu/45481)

<div class="topic-metadata">

**Author:** [@reid](https://discourse.julialang.org/u/reid)\
**Replies:** 3\
**Last updated:** [August 25, 2020, 1:40am UTC](https://discourse.julialang.org/t/taking-zygote-gradient-on-function-with-operator-fails-on-gpu/45481 "2020-08-25T01:40:09Z")

</div>

ERROR: LoadError: MethodError: no method matching !(::ForwardDiff.Dual{Nothing,Bool,1}) Only happens on gpu, not cpu, which is really confusing me. MWE using Flux masksum(x,y) = sum(.!x \* y) gradient(masksum, \[true,…

---

## [Onnx support for Julia ML frameworks](https://discourse.julialang.org/t/onnx-support-for-julia-ml-frameworks/9035)

<div class="topic-metadata">

**Author:** [@hgeorgako](https://discourse.julialang.org/u/hgeorgako)\
**Replies:** 9\
**Last updated:** [August 24, 2020, 8:35pm UTC](https://discourse.julialang.org/t/onnx-support-for-julia-ml-frameworks/9035 "2020-08-24T20:35:50Z")

</div>

This seems like it’s becoming a thing. https://onnx.ai/getting-started Any packages providing support for this?

---

## [\`CUDA error: out of memory\` with Flux](https://discourse.julialang.org/t/cuda-error-out-of-memory-with-flux/45269)

<div class="topic-metadata">

**Author:** [@natema](https://discourse.julialang.org/u/natema)\
**Replies:** 4\
**Last updated:** [August 24, 2020, 12:11pm UTC](https://discourse.julialang.org/t/cuda-error-out-of-memory-with-flux/45269 "2020-08-24T12:11:01Z")

</div>

I already posted about this issue here. After moving to Julia 1.5, I still get a similar error. When I run yiyu-test.jl I get ERROR: LoadError: CUDA error: out of memory (code 2, ERROR\_OUT\_OF\_MEMORY) Stacktrace: \[1\] …

---

## [Training gets differents results when using Flux.train() inside function](https://discourse.julialang.org/t/training-gets-differents-results-when-using-flux-train-inside-function/45284)

<div class="topic-metadata">

**Author:** [@german\_brunini](https://discourse.julialang.org/u/german_brunini)\
**Replies:** 2\
**Last updated:** [August 23, 2020, 11:01pm UTC](https://discourse.julialang.org/t/training-gets-differents-results-when-using-flux-train-inside-function/45284 "2020-08-23T23:01:36Z")

</div>

I am training a NN with some synthetic data. I was running everything on REPL and things were going on the right direction, but when I tried to wrap my code inside a function() to use custom training loops, my model(x) …

---

## [Error while trying to replicate a logistic regression problem using FluxML](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408)

<div class="topic-metadata">

**Author:** [@richie96](https://discourse.julialang.org/u/richie96)\
**Replies:** 5\
**Last updated:** [August 23, 2020, 1:31pm UTC](https://discourse.julialang.org/t/error-while-trying-to-replicate-a-logistic-regression-problem-using-fluxml/26408 "2020-08-23T13:31:03Z")

</div>

Hi, I have been trying to replicate the code from the following link to understand how to use ML in Julia better https://akaysh.github.io/Logistic-Regression-with-Julia/ While replicating I realized that when I ran th…

---

## [Computing null space of a Flux Chain](https://discourse.julialang.org/t/computing-null-space-of-a-flux-chain/45359)

<div class="topic-metadata">

**Author:** [@Jagirhussan](https://discourse.julialang.org/u/Jagirhussan)\
**Replies:** 8\
**Last updated:** [August 22, 2020, 11:32pm UTC](https://discourse.julialang.org/t/computing-null-space-of-a-flux-chain/45359 "2020-08-22T23:32:35Z")

</div>

I have trained a Flux Chain with Dense layers. I would like to determine the null space (the space of input vectors for which the output is zeros(s) ) for this Chain. I am looking for a Julia like way to determine the pr…

---

## [Scalar getindex during Flux gradient computation](https://discourse.julialang.org/t/scalar-getindex-during-flux-gradient-computation/45325)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 0\
**Last updated:** [August 21, 2020, 3:34pm UTC](https://discourse.julialang.org/t/scalar-getindex-during-flux-gradient-computation/45325 "2020-08-21T15:34:47Z")

</div>

I have a issue with a GPU scalar getindex during gradient computation with Flux. Problem is, I just can’t reproduce the problem with a simpler MWE. I swear I tried so hard. So here’s a chunk of the code and what I unders…

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

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