Getting error when use 7 lines of code in lesson1


(Chen) #1

when use 7 lines of code in lesson1:
But getting error

ValueError Traceback (most recent call last)
/home/cu_00170/nbs/dogcats.py in ()
13 np.set_printoptions(precision=4, linewidth=100)
14 from matplotlib import pyplot as plt
—> 15 import utils; reload(utils)
16 from utils import plots
17 path = “data/dogscats/sample/”

/home/cu_00170/nbs/utils.py in ()
31 from theano.tensor.signal import pool
32
—> 33 import keras
34 from keras import backend as K
35 from keras.utils.data_utils import get_file

/usr/local/lib/python2.7/dist-packages/keras/init.py in ()
1 from future import absolute_import
----> 2 from . import backend
3 from . import datasets
4 from . import engine
5 from . import layers

/usr/local/lib/python2.7/dist-packages/keras/backend/init.py in ()
32 _config_path = os.path.expanduser(os.path.join(_keras_dir, ‘keras.json’))
33 if os.path.exists(_config_path):
—> 34 _config = json.load(open(_config_path))
35 _floatx = _config.get(‘floatx’, floatx())
36 assert _floatx in {‘float16’, ‘float32’, ‘float64’}

/usr/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

/usr/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

/usr/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):

/usr/lib/python2.7/json/decoder.pyc in raw_decode(self, s, idx)
378 “”"
379 try:
–> 380 obj, end = self.scan_once(s, idx)
381 except StopIteration:
382 raise ValueError(“No JSON object could be decoded”)

ValueError: Expecting , delimiter: line 6 column 5 (char 122)

I don’t know what is wrong,because I don’t see the same error in forums .any ideas?


#2

It looks like the error is occurring while loading/parsing your keras.json configuration file. In ~/.keras/keras.json, you should have something that looks like this. Do you?

{
    "image_dim_ordering": "th",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "theano"
}

There is some discussion of this issue here. It sounds like uninstalling keras, deleting the ~/.keras subdirectory, and reinstalling Keras might fix your problem.

Good luck!


(Chen) #3

Thank you !I have this things in the file ~/.keras/keras.json.I have fixed it .I will try you suggestions later ,very thankful!


(Chen) #4

OK,it works,thanks for your suggestions


#5

Great to hear! Have fun.


(Paxton) #6

It was a bit tricky to get this right. In the end, what worked was:

  1. pip uninstall keras
  2. delete .keras folder in your home directory
  3. pip install keras==1.2.2
  4. re-start jupyter, and re- run the code from lesson1
  5. This will have created ~/.keras/keras.json.
  6. edit this file, and replace with following (it will have tensorflow by default):
    {
    “image_dim_ordering”: “th”,
    “epsilon”: 1e-07,
    “floatx”: “float32”,
    “backend”: “theano”
    }
  7. re-run the code and it should work now.

Cheers!