programing tip

tensorflow : AttributeError : 'module'객체에 'mul'속성이 없습니다.

itbloger 2020. 11. 10. 07:53
반응형

tensorflow : AttributeError : 'module'객체에 'mul'속성이 없습니다.


하루 동안 tensorflow를 사용했지만 몇 가지 문제가 있습니다. tensorflow를 가져올 때 AttributeError : 'module'object has no attribute 'XXXXXX'

환경

저는 ubuntu14.04, python2.7, CUDA 툴킷 8.0 및 CuDNN v5를 사용합니다. 내 six 및 protobuf의 버전은 다음과 같습니다. 이름 : six 버전 : 1.10.0 위치 : /usr/local/lib/python2.7/dist-packages 요구 사항 : 이름 : protobuf 버전 : 3.2.0 위치 : / usr / local / lib / python2.7 / dist-packages 필요 : 6 개, setuptools

내 테스트 코드는 다음과 같습니다.

import tensorflow as tf
a = tf.placeholder(tf.int16)
b = tf.placeholder(tf.int16)
add = tf.add(a, b)
mul = tf.mul(a, b)
with tf.Session() as sess:
    # Run every operation with variable input
    print "Addition with variables: %i" % sess.run(add, feed_dict={a: 2, b: 3})
    print "Multiplication with variables: %i" % sess.run(mul, feed_dict={a: 2, b: 3})

이 출력을 얻습니다.

여기에 이미지 설명 입력

tensorflow 설치에 문제가 있습니까? 또는 다른 문제?


tensorflow 1.0.0 릴리스 노트 에 따르면 ,

tf.mul, tf.subtf.neg찬성되지 않으며 tf.multiply, tf.subtract하고 tf.negative.

당신은 교체해야합니다 tf.mul함께 tf.multiply.


이 작업은 이전에 0.x 버전에서 사용할 수있었습니다. TF 1.0 출시 와 함께 API에 주요 변경 사항이 도입되었습니다 . 이외에

tf.mul, tf.subtf.neg대신 사용되지 않으며 tf.multiply, tf.subtracttf.negative

다른 많은 기능이 다음과 같은 이유에 따라 이름이 바뀌고 변경되었습니다.

여러 python API 호출이 NumPy와 더 유사하도록 변경되었습니다.

따라서 웹이나 책에서 이미 찾은 많은 스크립트가 작동하지 않습니다. 좋은 점은 대부분이 마이그레이션 스크립트 로 수정할 수 있다는 것입니다 . 로 실행할 수 있습니다 tf_upgrade.py --infile foo.py --outfile foo-upgraded.py. 모든 것을 해결할 수는 없지만 (제한 사항은 여기 에 나열되어 있음 ) 많은 작업을 절약 할 수 있습니다.


파이썬 3에서 사용하는 tf.multiply대신 tf.mul.

참고 URL : https://stackoverflow.com/questions/42217059/tensorflowattributeerror-module-object-has-no-attribute-mul

반응형