我试图使用Tensorflow(版本0.9.0)以与初学者教程非常相似的方式训练一个简单的二元逻辑回归分类器,并且在拟合模型时遇到以下错误:
ValueError: Tensor("centered_bias_weight:0", shape=(1,), dtype=float32_ref) must be from the same graph as Tensor("linear_14/BiasAdd:0", shape=(?, 1), dtype=float32).
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import tempfile
import tensorflow as tf
import pandas as pd
# Customized training data parsing
train_data = read_train_data()
feature_names = get_feature_names(train_data)
labels = get_labels(train_data)
# Construct dataframe from training data features
x_train = pd.DataFrame(train_data , columns=feature_names)
x_train["label"] = labels
y_train = tf.constant(labels)
# Create SparseColumn for each feature (assume all feature values are integers and either 0 or 1)
feature_cols = …Run Code Online (Sandbox Code Playgroud)