ValueError: No JSON object could be decoded

942 views
Skip to first unread message

dsu...@gmail.com

unread,
Dec 26, 2016, 7:33:03 PM12/26/16
to Keras-users

Hi all,

 

I have an issue with my keras setup on my new macbook pro. After installing (see setup below) first everything worked perfectly. I executed a test code using keras and it worked fine. After I edited keras.json to change the backend to theano it stopped working - even if I changed the backend back to tensorflow. It started to generate the error message below when importing Keras. 

…Any help would be highly appreciated.

 

Cheers, Daniel

 

My system: Macbook Pro, Mac OS 10.12.1, 16 GB Ram, Radeon 460

 

My installation procedure (in this order)

 

1. Install anaconda2 4.2.0 (python 2.7) for Mac OS X

2. Conda install Theano

3. Conda install Tensorflow (CPU only)

4. Pip install keras

 

keras.json

{

    "image_dim_ordering": "tf",

    "epsilon": 1e-07,

    "floatx": "float32",

    "backend": “theano”

}

 

Code which produces error (first line already generates error)

from keras.models import Sequential

from keras.layers import Dense

import numpy

 

 

 

Error message

 

ValueError                                Traceback (most recent call last)

<ipython-input-1-e15357e2bf6f> in <module>()

----> 1 from keras.models import Sequential

      2 from keras.layers import Dense

      3 import numpy

      4 # fix random seed for reproducibility

      5 seed = 7

 

//anaconda/lib/python2.7/site-packages/keras/__init__.py in <module>()

      1 from __future__ import absolute_import

----> 2 from . import backend

      3 from . import datasets

      4 from . import engine

      5 from . import layers

 

//anaconda/lib/python2.7/site-packages/keras/backend/__init__.py in <module>()

     29 _config_path = os.path.expanduser(os.path.join(_keras_dir, 'keras.json'))

     30 if os.path.exists(_config_path):

---> 31     _config = json.load(open(_config_path))

     32     _floatx = _config.get('floatx', floatx())

     33     assert _floatx in {'float16', 'float32', 'float64'}

 

//anaconda/lib/python2.7/json/__init__.pyc in load(fp, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)

    289         parse_float=parse_float, parse_int=parse_int,

    290         parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,

--> 291         **kw)

    292 

    293 

 

//anaconda/lib/python2.7/json/__init__.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)

    337             parse_int is None and parse_float is None and

    338             parse_constant is None and object_pairs_hook is None and not kw):

--> 339         return _default_decoder.decode(s)

    340     if cls is None:

    341         cls = JSONDecoder

 

//anaconda/lib/python2.7/json/decoder.pyc in decode(self, s, _w)

    362 

    363         """

--> 364         obj, end = self.raw_decode(s, idx=_w(s, 0).end())

    365         end = _w(s, end).end()

    366         if end != len(s):

 

//anaconda/lib/python2.7/json/decoder.pyc in raw_decode(self, s, idx)

    380             obj, end = self.scan_once(s, idx)

    381         except StopIteration:

--> 382             raise ValueError("No JSON object could be decoded")

    383         return obj, end

 

ValueError: No JSON object could be decoded

 

dsu...@gmail.com

unread,
Dec 26, 2016, 7:47:07 PM12/26/16
to Keras-users
I just discovered that just deleting the keras.json file and rerunning the code does the job. After that I am also able to switch btw. the two backends. Apparently the file was somehow corrupted but I don't understand why... would be interesting to know.

yixuan...@gmail.com

unread,
Feb 1, 2017, 7:09:24 PM2/1/17
to Keras-users
it happens to me too. Have you found the solution?  
Reply all
Reply to author
Forward
0 new messages