Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有多个标签的TensorFlow boostedTrees在步骤=0时停止_Tensorflow_Tensorflow2.0 - Fatal编程技术网

具有多个标签的TensorFlow boostedTrees在步骤=0时停止

具有多个标签的TensorFlow boostedTrees在步骤=0时停止,tensorflow,tensorflow2.0,Tensorflow,Tensorflow2.0,我面临使用BoostedTrees的tensorflow的一个问题,顺便说一下,我有一个数据集,其中可能有400个标签(从0到400编码)用于分类。 dataframe包含如下所述的8个功能,在训练这段代码时出现以下错误: df = pd.read_csv('trip.csv', sep=';') df = df[:10000] dftrain =df[['date_y','date_m','day','vehicle','device','start_h','start_m','tmt','l

我面临使用BoostedTrees的tensorflow的一个问题,顺便说一下,我有一个数据集,其中可能有400个标签(从0到400编码)用于分类。 dataframe包含如下所述的8个功能,在训练这段代码时出现以下错误:

df = pd.read_csv('trip.csv', sep=';')
df = df[:10000]
dftrain =df[['date_y','date_m','day','vehicle','device','start_h','start_m','tmt','label']]

#Omission of trivial details
...
###Scaling call
X_train_scaled = standardScaling(X_train)
X_test_scaled = standardScaling(X_test)
y_train
y_test

###feature columns
fc = tf.feature_column
feature_columns = []
NUMERIC_COLUMNS = ['date_y','date_m','day','vehicle','device','start_h','start_m','tmt']

for feature_name in NUMERIC_COLUMNS:
   feature_columns.append(fc.numeric_column(feature_name,
                                       dtype=tf.float32))
###input functions
# Use entire batch since this is such a small dataset.
NUM_EXAMPLES = len(y_train)

def make_input_fn(X, y, n_epochs=None, shuffle=True):
   def input_fn():
      dataset = tf.data.Dataset.from_tensor_slices((X.to_dict(orient='list'), y))
      if shuffle:
         dataset = dataset.shuffle(NUM_EXAMPLES)
      # For training, cycle thru dataset as many times as need (n_epochs=None).
      dataset = (dataset.repeat(n_epochs).batch(NUM_EXAMPLES))
      return dataset
   return input_fn

# Training and evaluation input functions.
train_input_fn = make_input_fn(X_train_scaled, y_train)
eval_input_fn = make_input_fn(X_test_scaled, y_test, shuffle=False, n_epochs=1)

#number of classes
n_c = int(max(np.unique(y))) + 1

#model
params = {
'n_trees': 20,
'max_depth': 4,
'n_batches_per_layer': 1,
'n_classes' : n_c,
# You must enable center_bias = True to get DFCs. This will force the model to
# make an initial prediction before using any features (e.g. use the mean of
# the training labels for regression or log odds for classification when
# using cross entropy loss).
'center_bias': False
}

est = tf.estimator.BoostedTreesClassifier(feature_columns, **params)
# Train model.
est.train(train_input_fn, max_steps=100)
# Evaluation.
results = est.evaluate(eval_input_fn)
clear_output()
pd.Series(results).to_frame()
print(pd.Series(results).to_frame())
通过执行,输出仅显示步骤=0并停止执行:

INFO:tensorflow:Using default config.
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpkhhkb7e5
INFO:tensorflow:Using config: {'_model_dir': '/tmp/tmpkhhkb7e5', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': allow_soft_placement: true
graph_options {
  rewrite_options {
    meta_optimizer_iterations: ONE
  }
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_checkpoint_save_graph_def': True, '_service': None, '_cluster_spec': ClusterSpec({}), '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:tensorflow:Calling model_fn.
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Create CheckpointSaverHook.
WARNING:tensorflow:Issue encountered when serializing resources.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
'_Resource' object has no attribute 'name'
INFO:tensorflow:Graph was finalized.
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
WARNING:tensorflow:Issue encountered when serializing resources.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
'_Resource' object has no attribute 'name'
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...
INFO:tensorflow:Saving checkpoints for 0 into /tmp/tmpkhhkb7e5/model.ckpt.
WARNING:tensorflow:Issue encountered when serializing resources.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
'_Resource' object has no attribute 'name'
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 0...
INFO:tensorflow:loss = 5.9322495, step = 0