The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Shuyib (21) [Avatar] Offline
#1
Hi,

I've just purchase the liveVideo. I was trying to move to theano and i'm getting an error. Before i show my error here how my json file looks like

{
    "floatx": "float32",
    "backend": "theano",
    "image_data_format": "channels_first",
    "epsilon": 1e-07
}

Then i change the backend to "theano" and image_data_format to "channels_last".

This is the error i'm getting.

/Users/brendamainye/anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using Theano backend.

You can find the C code in this temporary file: /var/folders/rd/xmt7lsxs4j95cdrp1ddl62v00000gn/T/theano_compilation_error_j055tq63
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~/anaconda/envs/py35/lib/python3.5/site-packages/theano/gof/lazylinker_c.py in <module>()
74 if version != getattr(lazylinker_ext, '_version', None):
---> 75 raise ImportError()
76 except ImportError:

ImportError:

During handling of the above exception, another exception occurred:
ImportError                               Traceback (most recent call last)
~/anaconda/envs/py35/lib/python3.5/site-packages/theano/gof/lazylinker_c.py in <module>()
     91             if version != getattr(lazylinker_ext, '_version', None):
---> 92                 raise ImportError()
     93         except ImportError:

ImportError: 

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-1-88d96843a926> in <module>()
----> 1 import keras

~/anaconda/envs/py35/lib/python3.5/site-packages/keras/__init__.py in <module>()
      1 from __future__ import absolute_import
      2 
----> 3 from . import utils
      4 from . import activations
      5 from . import applications

~/anaconda/envs/py35/lib/python3.5/site-packages/keras/utils/__init__.py in <module>()
      4 from . import data_utils
      5 from . import io_utils
----> 6 from . import conv_utils
      7 
      8 # Globally-importable utils.

~/anaconda/envs/py35/lib/python3.5/site-packages/keras/utils/conv_utils.py in <module>()
      7 from six.moves import range
      8 import numpy as np
----> 9 from .. import backend as K
     10 
     11 

~/anaconda/envs/py35/lib/python3.5/site-packages/keras/backend/__init__.py in <module>()
     78 elif _BACKEND == 'theano':
     79     sys.stderr.write('Using Theano backend.\n')
---> 80     from .theano_backend import *
     81 elif _BACKEND == 'tensorflow':
     82     sys.stderr.write('Using TensorFlow backend.\n')

~/anaconda/envs/py35/lib/python3.5/site-packages/keras/backend/theano_backend.py in <module>()
      5 from collections import defaultdict
      6 from contextlib import contextmanager
----> 7 import theano
      8 from theano import tensor as T
      9 from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams

~/anaconda/envs/py35/lib/python3.5/site-packages/theano/__init__.py in <module>()
    108     object2, utils)
    109 
--> 110 from theano.compile import (
    111     SymbolicInput, In,
    112     SymbolicOutput, Out,

~/anaconda/envs/py35/lib/python3.5/site-packages/theano/compile/__init__.py in <module>()
     10 from theano.compile.function_module import *
     11 
---> 12 from theano.compile.mode import *
     13 
     14 from theano.compile.io import *

~/anaconda/envs/py35/lib/python3.5/site-packages/theano/compile/mode.py in <module>()
      9 import theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano import config
     13 from six import string_types

~/anaconda/envs/py35/lib/python3.5/site-packages/theano/gof/vm.py in <module>()
    671     if not theano.config.cxx:
    672         raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 673     from . import lazylinker_c
    674 
    675     class CVM(lazylinker_c.CLazyLinker, VM):

~/anaconda/envs/py35/lib/python3.5/site-packages/theano/gof/lazylinker_c.py in <module>()
    125             args = cmodule.GCC_compiler.compile_args()
    126             cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 127                                              preargs=args)
    128             # Save version into the __init__.py file.
    129             init_py = os.path.join(loc, '__init__.py')

~/anaconda/envs/py35/lib/python3.5/site-packages/theano/gof/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2357             # difficult to read.
   2358             raise Exception('Compilation failed (return status=%s): %s' %
-> 2359                             (status, compile_stderr.replace('\n', '. ')))
   2360         elif config.cmodule.compilation_warning and compile_stderr:
   2361             # Print errors just below the command line.

Exception: Compilation failed (return status=1): In file included from /Users/brendamainye/.theano/compiledir_Darwin-15.6.0-x86_64-i386-64bit-i386-3.5.4-64/lazylinker_ext/mod.cpp:1:. In file included from /Users/brendamainye/anaconda/envs/py35/include/python3.5m/Python.h:25:. /Users/brendamainye/anaconda/envs/py35/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found. #include_next <stdio.h>.               ^~~~~~~~~. 1 error generated.. 


My Keras version 2.1.3

Please assist me to fix this.
Thanks in advance.
430476 (6) [Avatar] Offline
#2
Hmm, it would seem like there's a version mismatch between Keras and NumPy, or possibly Theano and NumPy. Given that Theano has stopped development since the release of this course, I would recommend switching to TensorFlow as the backend.
Shuyib (21) [Avatar] Offline
#3
Thanks. I'll just stick to TensorFlow. smilie