使用tensorflow1.5.1出现如下报错:

根据其他博客的报错分析添加链接描述,由于我所用的tensorflow为1.5.1版本,在import tensorflow as tf后添加tf.enable_eager_execution() 命令。
import numpy as np
import pandas as pd
import tensorflow as tf
tf.enable_eager_execution()
from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
值得注意的是,需要在最开始运行程序的时候运行该命令,否则会出现报错ValueError: tf.enable_eager_execution must be called at program startup.
在使用Tensorflow1.5.1时,导入库后需立即调用tf.enable_eager_execution()以避免程序运行时的ValueError。此错误提示表明启用eager_execution必须在程序开始时执行。文章提供了针对这个问题的解决方案。
2222

被折叠的 条评论
为什么被折叠?



