He usado tensorflow durante UN día, pero surgen algunos problemas, cuando importo tensorflow, habría AttributeError: el objeto 'módulo' no tiene el atributo 'XXXXXX'
Uso ubuntu14.04, python2.7, CUDA toolkit 8.0 y CuDNN v5. Y las versiones de my six y protobuf son: Nombre: six Versión: 1.10.0 Ubicación: /usr/local/lib/python2.7/dist-packages Requiere: Nombre: protobuf Versión: 3.2.0 Ubicación: /usr/local/ lib/python2.7/dist-packages Requiere: seis, herramientas de configuración
aquí está mi código de prueba:
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})Obtengo esta salida:
¿Hay algún problema con la instalación de tensorflow? o cualquier otro problema?
Según las notas de la versión de tensorflow 1.0.0 ,
tf.mul,tf.subytf.negestán en desuso en favor detf.multiply,tf.subtractytf.negative.
Deberá reemplazar tf.mul con tf.multiply .
Esta operación estaba disponible anteriormente en las versiones 0.x. Con el lanzamiento de TF 1.0, introdujeron cambios importantes en la API . Además de
tf.mul,tf.subytf.negestán en desuso en favor detf.multiply,tf.subtractytf.negative
muchas otras funciones fueron renombradas y modificadas con la siguiente justificación:
Se han cambiado varias llamadas a la API de Python para parecerse más a NumPy.
Así que muchos de los scripts que ya encontraste en la web o de los libros no funcionarán. Lo bueno es que la mayoría de ellos se pueden arreglar con su script de migración. Se puede ejecutar con tf_upgrade.py --infile foo.py --outfile foo-upgraded.py . No podrá resolver todo (las limitaciones se enumeran aquí ), pero le ahorrará mucho trabajo.
Respuesta compatible con 2.0 :
Los comandos para tf.multiply , si queremos migrar de Tensorflow 1.x a 2.x, se muestran a continuación:
tf.compat.v1.math.multiply, tf.compat.v1.multiply, tf.compat.v2.math.multiply, tf.compat.v2.multiply
Los comandos para tf.subtract , si queremos migrar de Tensorflow 1.x a 2.x, se muestran a continuación:
tf.compat.v1.math.subtract, tf.compat.v1.subtract, tf.compat.v2.math.subtract, tf.compat.v2.subtract
Los Comandos para tf.negative , si queremos migrar de Tensorflow 1.x a 2.x se muestran a continuación:
tf.compat.v1.math.negative, tf.compat.v1.negative, tf.compat.v2.math.negative, tf.compat.v2.negativeConsulte esta Guía de migración de Tensorflow para obtener más detalles.