Cannot assign value to variable named data

Here is MWE:

using Flux.Data.MNIST
data = 3

I get the error:

There is no variable called “data” in the Atom workspace: image

Any ideas? This is rather bothersome. I may have typed in, for testing reasons:

const data = ....

earlier during testing.

I also find that if I open another tab in Atom, and I do not create a module, I have access to all variables in the global space. That is somewhat bothersome to me.

Just don’t bring everything into your namespace

import Flux.Data.MNIST
const F = Flux.Data.MNIST
data = 3
F.data
1 Like

Thanks. So you would use the statement “import” rather than “using” for safety? Sounds reasonable and keeps the code cleaner. Most programmers do not appear to be doing this. I am looking at the examples for Flux in the zoo, and see programs that start as:


using Flux, Flux.Data.MNIST, Statistics

using Flux: throttle, params

using Juno: @progress

using Images

which seems like it would create all kinds of problems since one does not know what variables these packages contain.

Gordon

Yeah that’s fair. Sometimes it’s easier to write code without the prefix and you don’t always care where the code comes from, or its obvious where it comes from based on the context. It’s a matter of preference.

1 Like