質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

1回答

895閲覧

theano.functionでのエラー

wkumagai1001

総合スコア10

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2019/02/08 10:09

プログラミング初心者です. 深層学習に関して勉強しようと思い, 試しに theano を使った非常に短いコードを動かそうとしたところエラーが出てしましました. ### 発生している問題・エラーメッセージ

AttributeError Traceback (most recent call last)
<ipython-input-18-5991916882c4> in <module>()
6
7 x = theano.tensor.dscalar("x")
----> 8 f = theano.function(inputs=[x], outputs=x*2)

/Users/kumac/anaconda/lib/python3.6/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

/Users/kumac/anaconda/lib/python3.6/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

/Users/kumac/anaconda/lib/python3.6/site-packages/theano/compile/function_module.py in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
1793 on_unused_input=on_unused_input,
1794 output_keys=output_keys).create(
-> 1795 defaults)
1796
1797 t2 = time.time()

/Users/kumac/anaconda/lib/python3.6/site-packages/theano/compile/function_module.py in create(self, input_storage, trustme, storage_map)
1659 theano.config.traceback.limit = theano.config.traceback.compile_limit
1660 _fn, _i, _o = self.linker.make_thunk(
-> 1661 input_storage=input_storage_lists, storage_map=storage_map)
1662 finally:
1663 theano.config.traceback.limit = limit_orig

/Users/kumac/anaconda/lib/python3.6/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):

/Users/kumac/anaconda/lib/python3.6/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'):

/Users/kumac/anaconda/lib/python3.6/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.

/Users/kumac/anaconda/lib/python3.6/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

/Users/kumac/anaconda/lib/python3.6/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)

/Users/kumac/anaconda/lib/python3.6/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

/Users/kumac/anaconda/lib/python3.6/site-packages/theano/gof/cc.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, keep_lock)
1573 """
1574 try:
-> 1575 key = self.cmodule_key()
1576 except KeyError:
1577 key = None

/Users/kumac/anaconda/lib/python3.6/site-packages/theano/gof/cc.py in cmodule_key(self)
1269 libraries=self.libraries(),
1270 header_dirs=self.header_dirs(),
-> 1271 c_compiler=self.c_compiler(),
1272 )
1273

/Users/kumac/anaconda/lib/python3.6/site-packages/theano/gof/cc.py in cmodule_key_(self, fgraph, no_recycling, compile_args, libraries, header_dirs, insert_config_md5, c_compiler)
1348 # DynamicModule always add the include <numpy/arrayobject.h>
1349 sig.append('NPY_ABI_VERSION=0x%X' %
-> 1350 np.core.multiarray._get_ndarray_c_version())
1351 if c_compiler:
1352 sig.append('c_compiler_str=' + c_compiler.version_str())

AttributeError: ('The following error happened while compiling the node', Elemwise{mul,no_inplace}(TensorConstant{2.0}, x), '\n', "module 'numpy.core.multiarray' has no attribute '_get_ndarray_c_version'")

### 該当のソースコード ```Python import theano x = theano.tensor.dscalar('x') y = x ** 2 f = theano.function(inputs=[x], outputs=y)

試したこと

numpy と theano を入れ直しましたが直りませんでした.

補足情報(FW/ツールのバージョンなど)

以下はバージョン情報です.

Python 3.6.0
numpy 1.16.1
theano 0.9.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

numpyとtheanoのバージョンによっては、互換性が無いことでエラーが起こる可能性があります。

以下の環境では動作するので、バージョンを指定して再度インストールしてみてはいかがでしょうか。

python

1numpy 1.16.3 2theano 1.0.4

投稿2019/06/18 00:36

amahara_waya

総合スコア1029

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問