Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Tensorflow 2.0 - AttributeError: el módulo 'tensorflow' no tiene el atributo 'Sesión'

Cuando ejecuto el comando sess = tf.Session() en el entorno Tensorflow 2.0, recibo un mensaje de error como el siguiente:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'tensorflow' has no attribute 'Session'

Información del sistema:

  • Plataforma y distribución del sistema operativo: Windows 10
  • Versión de Python: 3.7.1
  • Versión de Tensorflow: 2.0.0-alpha0 (instalado con pip)

Pasos para reproducir:

Instalación:

  1. pip instalar --actualizar pip
  2. pip instalar tensorflow==2.0.0-alpha0
  3. pip instalar keras
  4. pip instalar numpy==1.16.2

Ejecución:

  1. Ejecutar comando: importar tensorflow como tf
  2. Ejecutar comando: sess = tf.Session()
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

De acuerdo con el TF 1:1 Symbols Map , en TF 2.0 debe usar tf.compat.v1.Session() en lugar de tf.Session()

https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0

Para obtener un comportamiento similar a TF 1.x en TF 2.0, se puede ejecutar

 import tensorflow.compat.v1 as tf tf.disable_v2_behavior()

pero entonces uno no puede beneficiarse de muchas mejoras realizadas en TF 2.0. Para obtener más detalles, consulte la guía de migración https://www.tensorflow.org/guide/migrate

over 4 years ago · Santiago Trujillo Report

0

TF2 ejecuta Eager Execution de forma predeterminada, eliminando así la necesidad de sesiones. Si desea ejecutar gráficos estáticos, la forma más adecuada es usar tf.function() en TF2. Si bien todavía se puede acceder a Session a través tf.compat.v1.Session() en TF2, desaconsejaría su uso. Puede ser útil demostrar esta diferencia comparando la diferencia en hola mundos:

TF1.x hola mundo:

 import tensorflow as tf msg = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(msg))

TF2.x hola mundo:

 import tensorflow as tf msg = tf.constant('Hello, TensorFlow!') tf.print(msg)

Para obtener más información, consulte Eficaz TensorFlow 2

over 4 years ago · Santiago Trujillo Report

0

Enfrenté este problema cuando probé python por primera vez después de instalar windows10 + python3.7(64bit) + anacconda3 + jupyter notebook.

Resolví este problema consultando " https://vispud.blogspot.com/2019/05/tensorflow200a0-attributeerror-module.html "

estoy de acuerdo con

Creo que "Sesión ()" se eliminó con TF 2.0.

Inserté dos líneas. Uno es tf.compat.v1.disable_eager_execution() y el otro es sess = tf.compat.v1.Session()

Mi Hello.py es el siguiente:

 import tensorflow as tf tf.compat.v1.disable_eager_execution() hello = tf.constant('Hello, TensorFlow!') sess = tf.compat.v1.Session() print(sess.run(hello))
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!