TFBlogs_2017
TFBlogs_2017 copied to clipboard
AttributeError: 'list' object has no attribute 'get_shape' running Blog_Estimators_DataSet
TensorFlow version: 1.6.0
AttributeError Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/tensorflow/python/data/ops/dataset_ops.pyc in map(self, map_func, num_parallel_calls) 788 """ 789 if num_parallel_calls is None: --> 790 return MapDataset(self, map_func) 791 else: 792 return ParallelMapDataset(self, map_func, num_parallel_calls)
/usr/local/lib/python2.7/dist-packages/tensorflow/python/data/ops/dataset_ops.pyc in init(self, input_dataset, map_func) 1595 1596 self._map_func = tf_map_func -> 1597 self._map_func.add_to_graph(ops.get_default_graph()) 1598 1599 def _as_variant_tensor(self):
/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/function.pyc in add_to_graph(self, g) 484 def add_to_graph(self, g): 485 """Adds this function into the graph g.""" --> 486 self._create_definition_if_needed() 487 488 # Adds this function into 'g'.
/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/function.pyc in _create_definition_if_needed(self) 319 """Creates the function definition if it's not created yet.""" 320 with context.graph_mode(): --> 321 self._create_definition_if_needed_impl() 322 323 def _create_definition_if_needed_impl(self):
/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/function.pyc in _create_definition_if_needed_impl(self) 336 # Call func and gather the output tensors. 337 with vs.variable_scope("", custom_getter=temp_graph.getvar): --> 338 outputs = self._func(*inputs) 339 340 # There is no way of distinguishing between a function not returning
/usr/local/lib/python2.7/dist-packages/tensorflow/python/data/ops/dataset_ops.pyc in tf_map_func(*args) 1583 self._output_classes = sparse.get_classes(ret) 1584 self._output_shapes = nest.pack_sequence_as( -> 1585 ret, [t.get_shape() for t in nest.flatten(ret)]) 1586 self._output_types = nest.pack_sequence_as( 1587 ret, [t.dtype for t in nest.flatten(ret)])
AttributeError: 'list' object has no attribute 'get_shape'
I think the problem is: label = parsed_line[-1:] # Last element is the label
should be label = parsed_line[-1] # Last element is the label
hi guys, I meet the same problem, can u help me? Thx! TensorFlow version is 1.8 my code is :
def decode_csv(line):
parsed_line = tf.decode_csv(line, [[0.], [0.], [0.], [0.], [0]])
return {'x': parsed_line[:-1]}, parsed_line[-1]
dataset = tf.data.TextLineDataset(file_path).skip(1).map(decode_csv)
the errors:
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 851, in map
return MapDataset(self, map_func)
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1839, in __init__
self._map_func.add_to_graph(ops.get_default_graph())
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\function.py", line 488, in add_to_graph
self._create_definition_if_needed()
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\function.py", line 321, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\function.py", line 338, in _create_definition_if_needed_impl
outputs = self._func(*inputs)
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1827, in tf_map_func
ret, [t.get_shape() for t in nest.flatten(ret)])
File "C:\Users\Jayce\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1827, in <listcomp>
ret, [t.get_shape() for t in nest.flatten(ret)])
AttributeError: 'list' object has no attribute 'get_shape'