0

以下のコードを実行すると、下記のエラーメッセージが出ます。

どなたか解決方法がわかる方教えてください。

import numpy as np
import os
import time
os.environ['MLU_VISIBLE_DEVICES']="0"
import tensorflow as tf
np.set_printoptions(suppress=True)
from power_diff_numpy import *

def power_difference_op(input_x, input_y, input_pow):
        with tf.Session() as sess:

                out = tf.power_difference()
                return sess.run(out, feed_dict = {x:input_x, y:input_y, pow:input_pow})

def main():
        value = 256
        input_x = np.random.randn(1,value,value,3)
        input_y = np.random.randn(1,1,1,3)
        input_pow = np.zeros((2))

        start = time.time()
        res = power_difference_op(input_x, input_y, input_pow)
        end = time.time() - start
        print("comput BCL op cost "+ str(end*1000) + "ms" )

        start = time.time()
        output = power_diff_numpy(input_x, input_y,len(input_pow))
        end = time.time()
        res = np.reshape(res,(-1))
        output = np.reshape(output,(-1))
        print("comput op cost "+ str((end-start)*1000) + "ms" )
        err = sum(abs(res - output))/sum(output)
        print("err rate= "+ str(err*100))

if __name__ == '__main__':
        main()   

元のソースコード:
https://github.com/leliyliu/ICS/blob/master/lab/lab1/code/src/online_mlu/power_difference_test_bcl.py#L11

WARNING:tensorflow:From power_difference_test_bcl.py:10: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

CNML: 7.2.1 c8ada41
CNRT: 4.2.1 fa5e44c
CNML: 7.2.1 c8ada41
CNML: 7.2.1 c8ada41
2020-12-05 05:24:10.892081: I tensorflow/stream_executor/mlu/mlu_stream_executor.cc:470][112186] MLU OP Cache enabled
CNML: 7.2.1 c8ada41
2020-12-05 05:24:10.892249: I tensorflow/core/common_runtime/mlu/mlu_device.cc:396][112186] __LOG_MLU__, Current MLU_Visible_Devices Count: 1
2020-12-05 05:24:10.892410: I tensorflow/core/common_runtime/mlu/mlu_device.cc:115][112186] __LOG_MLU__, save_offline_model: 0
2020-12-05 05:24:10.892487: I tensorflow/core/common_runtime/mlu/mlu_device.cc:121][112186] __LOG_MLU__, core_version: MLU270
2020-12-05 05:24:10.892584: I tensorflow/core/common_runtime/mlu/mlu_device.cc:123][112186] __LOG_MLU__, core_num: 1
Traceback (most recent call last):
  File "power_difference_test_bcl.py", line 36, in <module>
    main()
  File "power_difference_test_bcl.py", line 22, in main
    res = power_difference_op(input_x, input_y, input_pow)
  File "power_difference_test_bcl.py", line 12, in power_difference_op
    out = tf.power_difference()
  File "/opt/AICSE-demo-student/env/tensorflow-v1.10/virtualenv_mlu/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation_wrapper.py", line 106, in __getattr__
    attr = getattr(self._dw_wrapped_module, name)
AttributeError: 'module' object has no attribute 'power_difference'
5
  • 質問欄のコードは これ かと思いますが、コメントに # TODO:完成TensorFlow接口调用 と書かれています(おそらく中国語)。解決方法?は作者の人に聞くと良いのではないでしょうか。
    – user39889
    2020年12月5日 10:07
  • GitHubで直接聞くことってできますか?
    – Tak
    2020年12月5日 10:29
  • 作者の方が応えてくれる保証はありませんが、issues に Feature Request として投稿する事が考えられます。
    – user39889
    2020年12月5日 10:41
  • ありがとうございます!
    – Tak
    2020年12月5日 10:50
  • この問題と同じではないですか?stackoverflow.com/questions/56820327/… 2020年12月6日 10:24

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。