0

I'm running Python 3.6.8 and working in a virtual env with the following packages:

absl-py==0.8.0
astor==0.8.0
Click==7.0
cloudpickle==1.2.2
cycler==0.10.0
dask==2.5.0
dask-glm==0.2.0
dask-ml==1.0.0
distributed==2.5.1
fsspec==0.5.1
gast==0.3.2
google-pasta==0.1.7
grpcio==1.24.0
h5py==2.10.0
HeapDict==1.0.1
joblib==0.13.2
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.1.0
llvmlite==0.29.0
Markdown==3.1.1
matplotlib==3.1.1
msgpack==0.6.2
multipledispatch==0.6.0
numba==0.45.1
numpy==1.14.5
packaging==19.2
pandas==0.25.1
Pillow==6.1.0
protobuf==3.9.2
psutil==5.6.3
pyparsing==2.4.2
python-dateutil==2.8.0
pytz==2019.2
PyYAML==5.1.2
scikit-learn==0.21.3
scipy==1.3.1
seaborn==0.9.0
six==1.12.0
sortedcontainers==2.1.0
tblib==1.4.0
tensorboard==1.14.0
tensorflow==1.14.0
tensorflow-estimator==1.14.0
termcolor==1.1.0
toolz==0.10.0
tornado==6.0.3
Werkzeug==0.16.0
wrapt==1.11.2
zict==1.0.0

I'm following this tensorflow guide: https://www.tensorflow.org/tutorials/keras/classification

I'm loading the MNIST-Fashion dataset. The data is a vector with values ranging from 0 to 255. When I try to scale values between 0 and 1 (code at the bottom) i get the following error:

ValueError: output array is read-only

When I try to set the WRITTABLE flag to true I get the following error:

ValueError: cannot set WRITEABLE flag to True of this array

fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

train_images /= 255.0
test_images /= 255.0 

Adiotional info: I've tried to downgrade numpy to 1.14.5 and 1.15.4 and the error persists. Also, tensorflow 1.14.0 requires numpy 1.14.5 or superior.

Pepv
  • 76
  • 15

1 Answers1

0

The solution was very simple:

train_images = train_images/255.0
test_images = test_images/255.0 

instead of

train_images /= 255.0
test_images /= 255.0

Could someone explain the difference between one expression and the other please?

Pepv
  • 76
  • 15
  • 1
    https://stackoverflow.com/questions/63832055/why-does-raise-an-error-but-not-x-x-y-with-a-read-only-numpy-array – Peyman Sep 10 '20 at 15:12