Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datagen.standardize(x) alters original x #4724

Closed
trane293 opened this issue Dec 15, 2016 · 2 comments
Closed

datagen.standardize(x) alters original x #4724

trane293 opened this issue Dec 15, 2016 · 2 comments

Comments

@trane293
Copy link

Hello, recently I have noticed this issue that when I try to standardize my test set using my training data generator (let's call it "datagen"), using the line:

X_TEST_scaled = datagen.standardize(X_TEST)

It returns the scaled version of X_TEST, but it also alters the original X_TEST tensor, which makes me lose my original X_TEST data.

Please let me know if I am doing something wrong, or is this the intended behaviour (in which it's pretty weird).

@erilyth
Copy link
Contributor

erilyth commented Dec 20, 2016

@trane293 You would need to create a copy. Take a look at this http://stackoverflow.com/questions/3059395/numpy-array-assignment-problem

Solution: X_TEST_scaled = datagen.standardize(X_TEST.copy())

@trane293
Copy link
Author

Of course I can create a copy, that's what I've been doing to counter this issue. But I wanted to know if this is the intended behaviour or a bug with implementation? Traditionally functions don't modify arguments, and return new variables while preserving the arguments. This doesn't seem to be the case here.

@stale stale bot added the stale label May 23, 2017
@stale stale bot closed this as completed Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants