成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'

简介: 成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'

解决问题


image.png


AttributeError: 'MapDataset' object has no attribute 'group_by_window'



解决思路


错误属性:“mapdataset”对象没有“window”的“group”属性


A transformation that groups windows of elements by key and reduces them.


This transformation maps each consecutive element in a dataset to a key using key_func and groups the elements by key. It then applies reduce_func to at most window_size_func(key) elements matching the same key. All except the final window for each key will contain window_size_func(key) elements; the final window may be smaller.


You may provide either a constant window_size or a window size determined by the key through window_size_func.


Args:


key_func: A function mapping a nested structure of tensors (having shapes and types defined by self.output_shapes and self.output_types) to a scalar tf.int64 tensor.

reduce_func: A function mapping a key and a dataset of up to window_size consecutive elements matching that key to another dataset.

window_size: A tf.int64 scalar tf.Tensor, representing the number of consecutive elements matching the same key to combine in a single batch, which will be passed to reduce_func. Mutually exclusive with window_size_func.

window_size_func: A function mapping a key to a tf.int64 scalar tf.Tensor, representing the number of consecutive elements matching the same key to combine in a single batch, which will be passed to reduce_func. Mutually exclusive with window_size.

Returns:


A Dataset transformation function, which can be passed to tf.data.Dataset.apply.


Raises:


ValueError: if neither or both of {window_size, window_size_func} are passed.


解决方法


'MapDataset' 这种对象,没有'group_by_window'这种属性。


tf.contrib.data.group_by_window(

   key_func,

   reduce_func,

   window_size=None,

   window_size_func=None

)

   # batched_dataset = src_tgt_dataset.group_by_window(

   #     key_func=key_func, reduce_func=reduce_func, window_size=batch_size)

   #20180626修改此处

   batched_dataset = src_tgt_dataset.apply(

       tf.contrib.data.group_by_window(

           key_func=key_func, reduce_func=reduce_func, window_size=batch_size))




相关文章
|
1月前
|
计算机视觉 Python
解决 NoneType‘ object has no attribute ‘astype’ 问题
解决 NoneType‘ object has no attribute ‘astype’ 问题
30 0
|
5月前
|
存储 JSON 数据格式
数据集加载时报错'dict' object has no attribute 'requests‘
数据集加载时报错'dict' object has no attribute 'requests‘
108 5
|
3月前
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
366 0
|
6月前
|
Python Windows
xlrd库报错【AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘】
xlrd库报错【AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘】
117 0
|
3月前
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
92 0
|
4月前
|
数据采集
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
246 0
|
4月前
'WebDriver' object has no attribute 'find_element_by_tag_name'
'WebDriver' object has no attribute 'find_element_by_tag_name'
118 0
|
8月前
yolov7—tensorrt报错AttributeError: ‘NoneType‘ object has no attribute ‘execute_v2‘已解决。
yolov7—tensorrt报错AttributeError: ‘NoneType‘ object has no attribute ‘execute_v2‘已解决。
86 0
yolov7—tensorrt报错AttributeError: ‘NoneType‘ object has no attribute ‘execute_v2‘已解决。
|
5月前
|
Java
java判断Object对象是否为空demo
java判断Object对象是否为空demo
|
14天前
|
JavaScript
js 字符串String转对象Object
该代码示例展示了如何将一个以逗号分隔的字符串(`'1.2,2,3,4,5'`)转换为对象数组。通过使用`split(',')`分割字符串并`map(parseFloat)`处理每个元素,将字符串转换成浮点数数组,最终得到一个对象数组,其类型为`object`。