I got my own data for training, etc in TensorFlow. I got the Load CSV Data tutorial from TensorFlow on Colab , and I changed the config on some of the variables to match my data. When I ran the program, I got this error:
/tensorflow-2.0.0/python3.6/tensorflow_core/python/autograph/impl/api.py in wrapper(*args, **kwargs)
235 except Exception as e: # pylint:disable=broad-except
236 if hasattr(e, 'ag_error_metadata'):
--> 237 raise e.ag_error_metadata.to_exception(e)
238 else:
239 raise
TypeError: in converted code:
<ipython-input-15-ed03747f8311>:2 pack *
return tf.stack(list(features.values()), axis=-1), label
/tensorflow-2.0.0/python3.6/tensorflow_core/python/util/dispatch.py:180 wrapper
return target(*args, **kwargs)
/tensorflow-2.0.0/python3.6/tensorflow_core/python/ops/array_ops.py:1165 stack
return gen_array_ops.pack(values, axis=axis, name=name)
/tensorflow-2.0.0/python3.6/tensorflow_core/python/ops/gen_array_ops.py:6304 pack
"Pack", values=values, axis=axis, name=name)
/tensorflow-2.0.0/python3.6/tensorflow_core/python/framework/op_def_library.py:499 _apply_op_helper
raise TypeError("%s that don't all match." % prefix)
TypeError: Tensors in list passed to 'values' of 'Pack' Op have types [string, float32] that don't all match.
The whole output of the block is available here on Pastebin .
The block ran in the tutorial is:
packed_dataset = temp_dataset.map(pack)
for features, labels in packed_dataset.take(1):
print(features.numpy())
print()
print(labels.numpy())
I solved my problem.
I accidentaly forgot that my 1st column was not numeric, so I removed it from the list.
# Before Stuff
After Stuff
# SELECT_COLUMNS = ['sid', 'dist', 'microtime']
SELECT_COLUMNS = ['dist', 'microtime']
# DEFAULTS = ['a_r_d_b_id', 0.0, 0.0]
DEFAULTS = [0.0, 0.0]
temp_dataset = get_dataset(train_file_path,
select_columns=SELECT_COLUMNS,
column_defaults = DEFAULTS)
show_batch(temp_dataset)
example_batch, labels_batch = next(iter(temp_dataset))
def pack(features, label):
return tf.stack(list(features.values()), axis=-1), label
packed_dataset = temp_dataset.map(pack)
for features, labels in packed_dataset.take(1):
print(features.numpy())
print()
print(labels.numpy())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.