Reputation: 35692
I have the following tensorflow 1.0 code:
import tensorflow as tf
feature_cols = tf.contrib.learn.infer_real_valued_columns_from_input(X_train)
dnn_clf = tf.contrib.learn.DNNClassifier(hidden_units=[300,100], n_classes=10,
feature_columns=feature_cols)
dnn_clf = tf.contrib.learn.SKCompat(dnn_clf) # if TensorFlow >= 1.1
dnn_clf.fit(X_train, y_train, batch_size=50, steps=40000)
When I try to run the converter:
tf_upgrade_v2 --infile mlp.py --outfile mlp2.py
I get the following error:
--------------------------------------------------------------------------------
File: mlp.py
--------------------------------------------------------------------------------
mlp.py:3:15: ERROR: Using member tf.contrib.learn.infer_real_valued_columns_from_input in
deprecated module tf.contrib. tf.contrib.learn.infer_real_valued_columns_from_input cannot be converted automatically. tf.contrib will not be distributed with TensorFlow 2.0, please
consider an alternative in non-contrib TensorFlow, a community-maintained repository such as
tensorflow/addons, or fork the required code.
mlp.py:4:10: ERROR: Using member tf.contrib.learn.DNNClassifier in deprecated module tf.contrib. tf.contrib.learn.DNNClassifier cannot be converted automatically. tf.contrib will not be distributed with TensorFlow 2.0, please consider an alternative in non-contrib TensorFlow, a community-maintained repository such as tensorflow/addons, or fork the required code.
mlp.py:6:10: ERROR: Using member tf.contrib.learn.SKCompat in deprecated module tf.contrib. tf.contrib.learn.SKCompat cannot be converted automatically. tf.contrib will not be distributed with TensorFlow 2.0, please consider an alternative in non-contrib TensorFlow, a community-maintained repository such as tensorflow/addons, or fork the required code.
My question is: How to convert this tensorflow 1.0 code to tensorflow 2.0 when the upgrade script fails?
Upvotes: 0
Views: 387
Reputation:
Some of the Tensorflow 1.x libraries are moved to Tensorflow/addons
and few of them are replaced with Tensorflow.Estimator
in Tensorflow 2.x.
tf_upgrade_v2
script will not completely upgrade code from Tfv1.x to Tfv2.x.
This script will accelerate your upgrade process by converting existing TensorFlow 1.x Python scripts to TensorFlow 2.0.
In this case tf.contrib.learn
is replaced with Estimator.
TF2.x compatible code: Replace
tf.contrib.learn.DNNLinearCombinedRegressor
with
tf.estimator.DNNLinearCombinedRegressor
Take a look at this link for more information
Upvotes: 1