2017-03-19 49 views
1

我是完全新的keras和開始,我試圖按照this教程。我使用theano後端。 可悲的是,我已經在這條線遇到的困難:這條線爲什麼會產生錯誤?

model.add(Dense(num_pixels, input_dim=num_pixels, init='normal', activation='relu')) 

它說:

UserWarning: Update your Dense call to the Keras 2 API: Dense(784, input_dim=784, activation="relu", kernel_initializer="normal") '` call to the Keras 2 API: ' + signature)

INFO (theano.gof.compilelock): Refreshing lock [...]

將引發錯誤,以及: 導入錯誤:DLL加載失敗:一個動態鏈接庫(DLL) 初始化例程失敗。

我在做什麼錯?每一個想法是極大的讚賞:d

下面是完整的錯誤回溯(部分德國):

--------------------------------------------------------------------------- 
ImportError        Traceback (most recent call last) 
<ipython-input-59-12b29e43ecfe> in <module>() 
----> 1 model = baseline_model() 
     2 
     3 model.fit(x_train, y_train, validation_data=(x_test, y_test), nb_epoch=10, batch_size=200, verbose=2) 
     4 
     5 scores = model.evaluate(x_test, y_test, verbose=0) 

<ipython-input-57-16bc1d352f3b> in baseline_model() 
     2  model = Sequential() #RNN? 
     3  #InputLayer 
----> 4  model.add(Dense(num_pixels, input_dim=num_pixels, init='normal', activation='relu')) 
     5  #OutputLayer 
     6  model.add(Dense(num_classes, init='normal', activation='softmax')) 

C:\ProgramData\Anaconda3\lib\site-packages\keras\models.py in add(self, layer) 
    420     # and create the node connecting the current layer 
    421     # to the input layer we just created. 
--> 422     layer(x) 
    423 
    424    if len(layer.inbound_nodes) != 1: 

C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py in __call__(self, inputs, **kwargs) 
    526           '`layer.build(batch_input_shape)`') 
    527     if len(input_shapes) == 1: 
--> 528      self.build(input_shapes[0]) 
    529     else: 
    530      self.build(input_shapes) 

C:\ProgramData\Anaconda3\lib\site-packages\keras\layers\core.py in build(self, input_shape) 
    825          name='kernel', 
    826          regularizer=self.kernel_regularizer, 
--> 827          constraint=self.kernel_constraint) 
    828   if self.use_bias: 
    829    self.bias = self.add_weight((self.units,), 

C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py in add_weight(self, shape, initializer, name, trainable, regularizer, constraint) 
    362   """ 
    363   initializer = initializers.get(initializer) 
--> 364   weight = K.variable(initializer(shape), dtype=K.floatx(), name=name) 
    365   if regularizer is not None: 
    366    self.add_loss(regularizer(weight)) 

C:\ProgramData\Anaconda3\lib\site-packages\keras\initializers.py in __call__(self, shape, dtype) 
    71  def __call__(self, shape, dtype=None): 
    72   return K.random_normal(shape, self.mean, self.stddev, 
---> 73        dtype=dtype, seed=self.seed) 
    74 
    75  def get_config(self): 

C:\ProgramData\Anaconda3\lib\site-packages\keras\backend\theano_backend.py in random_normal(shape, mean, stddev, dtype, seed) 
    1935   seed = np.random.randint(1, 10e6) 
    1936  rng = RandomStreams(seed=seed) 
-> 1937  return rng.normal(size=shape, avg=mean, std=stddev, dtype=dtype) 
    1938 
    1939 

C:\ProgramData\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in normal(self, size, avg, std, ndim, dtype, nstreams) 
    1572    n_samples = prod(size) + (prod(size) % 2) 
    1573   flattened = self.uniform(size=(n_samples,), dtype=dtype, 
-> 1574         nstreams=nstreams) 
    1575 
    1576   if constant: 

C:\ProgramData\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in uniform(self, size, low, high, ndim, dtype, nstreams) 
    1352   if nstreams is None: 
    1353    nstreams = self.n_streams(size) 
-> 1354   rstates = self.get_substream_rstates(nstreams, dtype) 
    1355 
    1356   if self.use_cuda and dtype == 'float32': 

C:\ProgramData\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 

C:\ProgramData\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in get_substream_rstates(self, n_streams, dtype, inc_rstate) 
    1254   # If multMatVect.dot_modulo isn't compiled, compile it. 
    1255   if multMatVect.dot_modulo is None: 
-> 1256    multMatVect(rval[0], A1p72, M1, A2p72, M2) 
    1257 
    1258   # This way of calling the Theano fct is done to bypass Theano overhead. 

C:\ProgramData\Anaconda3\lib\site-packages\theano\sandbox\rng_mrg.py in multMatVect(v, A, m1, B, m2) 
    64   o = DotModulo()(A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym) 
    65   multMatVect.dot_modulo = function(
---> 66    [A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym], o, profile=False) 
    67 
    68  # This way of calling the Theano fct is done to bypass Theano overhead. 

C:\ProgramData\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) 
    324     on_unused_input=on_unused_input, 
    325     profile=profile, 
--> 326     output_keys=output_keys) 
    327  # We need to add the flag check_aliased inputs if we have any mutable or 
    328  # borrowed used defined inputs 

C:\ProgramData\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 

C:\ProgramData\Anaconda3\lib\site-packages\theano\compile\function_module.py in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys) 
    1794     on_unused_input=on_unused_input, 
    1795     output_keys=output_keys).create(
-> 1796    defaults) 
    1797 
    1798  t2 = time.time() 

C:\ProgramData\Anaconda3\lib\site-packages\theano\compile\function_module.py in create(self, input_storage, trustme, storage_map) 
    1660    theano.config.traceback.limit = theano.config.traceback.compile_limit 
    1661    _fn, _i, _o = self.linker.make_thunk(
-> 1662     input_storage=input_storage_lists, storage_map=storage_map) 
    1663   finally: 
    1664    theano.config.traceback.limit = limit_orig 

C:\ProgramData\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): 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\vm.py in make_all(self, profiler, input_storage, output_storage, storage_map) 
    1045             compute_map, 
    1046             no_recycling, 
-> 1047             impl=impl)) 
    1048     linker_make_thunk_time[node] = time.time() - thunk_start 
    1049     if not hasattr(thunks[-1], 'lazy'): 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl) 
    933    try: 
    934     return self.make_c_thunk(node, storage_map, compute_map, 
--> 935           no_recycling) 
    936    except (NotImplementedError, utils.MethodNotDefined): 
    937     # We requested the c code, so don't catch the error. 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling) 
    837   _logger.debug('Trying CLinker.make_thunk') 
    838   outputs = cl.make_thunk(input_storage=node_input_storage, 
--> 839         output_storage=node_output_storage) 
    840   fill_storage, node_input_filters, node_output_filters = outputs 
    841 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cc.py in make_thunk(self, input_storage, output_storage, storage_map, keep_lock) 
    1188   cthunk, in_storage, out_storage, error_storage = self.__compile__(
    1189    input_storage, output_storage, storage_map, 
-> 1190    keep_lock=keep_lock) 
    1191 
    1192   res = _CThunk(cthunk, init_tasks, tasks, error_storage) 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cc.py in __compile__(self, input_storage, output_storage, storage_map, keep_lock) 
    1129          output_storage, 
    1130          storage_map, 
-> 1131          keep_lock=keep_lock) 
    1132   return (thunk, 
    1133     [link.Container(input, storage) for input, storage in 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cc.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, keep_lock) 
    1584     node.op.prepare_node(node, storage_map, None, 'c') 
    1585    module = get_module_cache().module_from_key(
-> 1586     key=key, lnk=self, keep_lock=keep_lock) 
    1587 
    1588   vars = self.inputs + self.outputs + self.orphans 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cmodule.py in module_from_key(self, key, lnk, keep_lock) 
    1157    try: 
    1158     location = dlimport_workdir(self.dirname) 
-> 1159     module = lnk.compile_cmodule(location) 
    1160     name = module.__file__ 
    1161     assert name.startswith(location) 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cc.py in compile_cmodule(self, location) 
    1487     lib_dirs=self.lib_dirs(), 
    1488     libs=libs, 
-> 1489     preargs=preargs) 
    1490   except Exception as e: 
    1491    e.args += (str(self.fgraph),) 

C:\ProgramData\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) 
    2345    open(os.path.join(location, "__init__.py"), 'w').close() 
    2346    assert os.path.isfile(lib_filename) 
-> 2347    return dlimport(lib_filename) 
    2348 
    2349 

C:\ProgramData\Anaconda3\lib\site-packages\theano\gof\cmodule.py in dlimport(fullpath, suffix) 
    300    warnings.filterwarnings("ignore", 
    301          message="numpy.ndarray size changed") 
--> 302    rval = __import__(module_name, {}, {}, [module_name]) 
    303   t1 = time.time() 
    304   import_time += t1 - t0 

ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen. 
+0

對我來說,這似乎只是**警告**,而不是**錯誤**。代碼應該按預期工作。 –

+0

對不起,我忘了提到這個:之後,它在這條線上拋出一個ImportError – TTF

+2

然後在你的問題中包含完整的錯誤回溯。 –

回答

相關問題