我正在尝试在[https://blog.eduonix.com/internet-of-things/simple-nlp-based-chatbot-python/]链接中运行代码段,但是keras顺序模型不适用于cutils_ext
。
我正在将Anaconda与python 3.7.0一起使用
我尝试了import cutils_ext
,此方法有效,但是from cutils_ext.cutils_ext import *
不适用于
model.add(Dense(units=64, activation='sigmoid',input_dim=len(X_train[0])))
我尝试使用pip安装相同的库,但出现以下错误,
Could not find a version that satisfies the requirement cutils_ext.cutils_ext (from versions: ) No matching distribution found for cutils_ext.cutils_ext
导入theano和keras都效果很好。我的Keras使用theano后端,因为tensorlow尚未针对python 3.7发布
我得到的错误如下,
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\theano\gof\cutils.py in <module>()
111 try:
--> 112 from cutils_ext.cutils_ext import * # noqa
113 except ImportError:
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\theano\gof\cutils.py in <module>()
122 # and when we receive the lock
--> 123 from cutils_ext.cutils_ext import * # noqa
124 except ImportError:
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-20-98a41b7df464> in <module>()
6 model = Sequential()
7 model.add(Dense(units=64, activation='sigmoid',
----> 8 input_dim=len(X_train[0])))
~\Anaconda3\lib\site-packages\keras\engine\sequential.py in add(self, layer)
163 # and create the node connecting the current layer
164 # to the input layer we just created.
--> 165 layer(x)
166 set_inputs = True
167 else:
~\Anaconda3\lib\site-packages\keras\engine\base_layer.py in __call__(self, inputs, **kwargs)
429 'You can build it manually via: '
430 '`layer.build(batch_input_shape)`')
--> 431 self.build(unpack_singleton(input_shapes))
432 self.built = True
433
~\Anaconda3\lib\site-packages\keras\layers\core.py in build(self, input_shape)
864 name='kernel',
865 regularizer=self.kernel_regularizer,
--> 866 constraint=self.kernel_constraint)
867 if self.use_bias:
868 self.bias = self.add_weight(shape=(self.units,),
~\Anaconda3\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your `' + object_name + '` call to the ' +
90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper
~\Anaconda3\lib\site-packages\keras\engine\base_layer.py in add_weight(self, name, shape, dtype, initializer, regularizer, trainable, constraint)
247 if dtype is None:
248 dtype = K.floatx()
--> 249 weight = K.variable(initializer(shape),
250 dtype=dtype,
251 name=name,
~\Anaconda3\lib\site-packages\keras\initializers.py in __call__(self, shape, dtype)
216 limit = np.sqrt(3. * scale)
217 return K.random_uniform(shape, -limit, limit,
--> 218 dtype=dtype, seed=self.seed)
219
220 def get_config(self):
~\Anaconda3\lib\site-packages\keras\backend\theano_backend.py in random_uniform(shape, minval, maxval, dtype, seed)
2598 seed = np.random.randint(1, 10e6)
2599 rng = RandomStreams(seed=seed)
-> 2600 return rng.uniform(shape, low=minval, high=maxval, dtype=dtype)
2601
2602
~\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in uniform(self, size, low, high, ndim, dtype, nstreams, **kwargs)
870 if nstreams is None:
871 nstreams = self.n_streams(size)
--> 872 rstates = self.get_substream_rstates(nstreams, dtype)
873
874 d = {}
~\Anaconda3\lib\site-packages\theano\configparser.py in res(*args, **kwargs)
115 def res(*args, **kwargs):
116 with self:
--> 117 return f(*args, **kwargs)
118 return res
119
~\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in get_substream_rstates(self, n_streams, dtype, inc_rstate)
777 # If multMatVect.dot_modulo isn't compiled, compile it.
778 if multMatVect.dot_modulo is None:
--> 779 multMatVect(rval[0], A1p72, M1, A2p72, M2)
780
781 # This way of calling the Theano fct is done to bypass Theano overhead.
~\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in multMatVect(v, A, m1, B, m2)
60 o = DotModulo()(A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym)
61 multMatVect.dot_modulo = function(
---> 62 [A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym], o, profile=False)
63
64 # This way of calling the Theano fct is done to bypass Theano overhead.
~\Anaconda3\lib\site-packages\theano\compile\function.py in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
315 on_unused_input=on_unused_input,
316 profile=profile,
--> 317 output_keys=output_keys)
318 return fn
~\Anaconda3\lib\site-packages\theano\compile\pfunc.py in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys)
484 accept_inplace=accept_inplace, name=name,
485 profile=profile, on_unused_input=on_unused_input,
--> 486 output_keys=output_keys)
487
488
~\Anaconda3\lib\site-packages\theano\compile\function_module.py in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
1839 name=name)
1840 with theano.change_flags(compute_test_value="off"):
-> 1841 fn = m.create(defaults)
1842 finally:
1843 t2 = time.time()
~\Anaconda3\lib\site-packages\theano\compile\function_module.py in create(self, input_storage, trustme, storage_map)
1713 theano.config.traceback.limit = theano.config.traceback.compile_limit
1714 _fn, _i, _o = self.linker.make_thunk(
-> 1715 input_storage=input_storage_lists, storage_map=storage_map)
1716 finally:
1717 theano.config.traceback.limit = limit_orig
~\Anaconda3\lib\site-packages\theano\gof\link.py in make_thunk(self, input_storage, output_storage, storage_map)
697 return self.make_all(input_storage=input_storage,
698 output_storage=output_storage,
--> 699 storage_map=storage_map)[:3]
700
701 def make_all(self, input_storage, output_storage):
~\Anaconda3\lib\site-packages\theano\gof\vm.py in make_all(self, profiler, input_storage, output_storage, storage_map)
1089 compute_map,
1090 [],
-> 1091 impl=impl))
1092 linker_make_thunk_time[node] = time.time() - thunk_start
1093 if not hasattr(thunks[-1], 'lazy'):
~\Anaconda3\lib\site-packages\theano\gof\op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
953 try:
954 return self.make_c_thunk(node, storage_map, compute_map,
--> 955 no_recycling)
956 except (NotImplementedError, utils.MethodNotDefined):
957 # We requested the c code, so don't catch the error.
~\Anaconda3\lib\site-packages\theano\gof\op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
856 _logger.debug('Trying CLinker.make_thunk')
857 outputs = cl.make_thunk(input_storage=node_input_storage,
--> 858 output_storage=node_output_storage)
859 thunk, node_input_filters, node_output_filters = outputs
860
~\Anaconda3\lib\site-packages\theano\gof\cc.py in make_thunk(self, input_storage, output_storage, storage_map, keep_lock)
1217 keep_lock=keep_lock)
1218
-> 1219 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)
1220 res.nodes = self.node_order
1221 return res, in_storage, out_storage
~\Anaconda3\lib\site-packages\theano\gof\cc.py in __init__(self, cthunk, init_tasks, tasks, error_storage, module)
1691 if run_cthunk is None:
1692 # Lazy import to avoid compilation when importing theano.
-> 1693 from theano.gof.cutils import run_cthunk # noqa
1694 self.cthunk = cthunk
1695 self.init_tasks = init_tasks
~\Anaconda3\lib\site-packages\theano\gof\cutils.py in <module>()
124 except ImportError:
125
--> 126 compile_cutils()
127 from cutils_ext.cutils_ext import * # noqa
128
~\Anaconda3\lib\site-packages\theano\gof\cutils.py in compile_cutils()
89 args = cmodule.GCC_compiler.compile_args(march_flags=False)
90 cmodule.GCC_compiler.compile_str('cutils_ext', code, location=loc,
---> 91 preargs=args)
92
93 try:
~\Anaconda3\lib\site-packages\theano\gof\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2395 open(os.path.join(location, "__init__.py"), 'w').close()
2396 assert os.path.isfile(lib_filename)
-> 2397 return dlimport(lib_filename)
2398
2399
~\Anaconda3\lib\site-packages\theano\gof\cmodule.py in dlimport(fullpath, suffix)
307 warnings.filterwarnings("ignore",
308 message="numpy.ndarray size changed")
--> 309 rval = __import__(module_name, {}, {}, [module_name])
310 t1 = time.time()
311 import_time += t1 - t0
ImportError: DLL load failed: The specified procedure could not be found.
如何解决问题并运行keras模型?请指导。 TIA