

下記のコードを実行すると、エラーメッセージが表示されてしまいます。  
どなたか解決方法がわかる方教えてください。

**エラーメッセージ:**

[code]

    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'
    
[/code]

**ソースコード:**

[code]

    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()   
    
[/code]


CC BY-SA 4.0
2020-12-05T06:26:29.737
72417
2020-12-05T12:07:01.040
2020-12-05T12:07:00.780
3060
43019
question
python tensorflow
エラーを解決したい : AttributeError: 'module' object has no attribute 'power_difference'