Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
tensorflow:AttributeError: 'module' object has no attribute 'mul'

I have used tensorflow for ONE day,but there comes some troubles,when I import tensorflow, there would be AttributeError: 'module' object has no attribute 'XXXXXX'

Environment

I use ubuntu14.04, python2.7, CUDA toolkit 8.0 and CuDNN v5. And versions of my six and protobuf are: Name: six Version: 1.10.0 Location: /usr/local/lib/python2.7/dist-packages Requires: Name: protobuf Version: 3.2.0 Location: /usr/local/lib/python2.7/dist-packages Requires: six, setuptools

here is my test code:

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})

I get this output:

enter image description here

Is there any problem with the tensorflow installation? or any other problems?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

According to the tensorflow 1.0.0 release notes,

tf.mul, tf.sub and tf.neg are deprecated in favor of tf.multiply, tf.subtract and tf.negative.

You'll need to replace tf.mul with tf.multiply.

over 4 years ago · Santiago Trujillo Denunciar

0

This operation was previously available in 0.x versions. With the release of TF 1.0 they introduced breaking changes to the API. In addition to

tf.mul, tf.sub and tf.neg are deprecated in favor of tf.multiply, tf.subtract and tf.negative

many other functions were renamed and changed with the following justification:

Several python API calls have been changed to resemble NumPy more closely.

So a lot of the scripts that you already found on the web or from the books will not work. Good thing is that majority of them can be fixed with their migration script. It can be run with tf_upgrade.py --infile foo.py --outfile foo-upgraded.py. It will not be able to solve everything (limitations are listed here), but will save you a lot of work.

over 4 years ago · Santiago Trujillo Denunciar

0

2.0 Compatible Answer:

The Commands for tf.multiply, if we want to migrate from Tensorflow 1.x to 2.x are shown below:

tf.compat.v1.math.multiply, tf.compat.v1.multiply, tf.compat.v2.math.multiply, tf.compat.v2.multiply

The Commands for tf.subtract, if we want to migrate from Tensorflow 1.x to 2.x are shown below:

tf.compat.v1.math.subtract, tf.compat.v1.subtract, tf.compat.v2.math.subtract, tf.compat.v2.subtract

The Commands for tf.negative, if we want to migrate from Tensorflow 1.x to 2.x are shown below:

tf.compat.v1.math.negative, tf.compat.v1.negative, tf.compat.v2.math.negative, 
tf.compat.v2.negative

See this Tensorflow Migration Guide for more details.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda