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


羞涩踢鞋子
羞涩踢鞋子 2022-09-19 17:23:10 49664
分类专栏: 资讯

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

目录

解决问题

解决思路

解决方法


解决问题

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:

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

Raises:

  • ValueError: if neither or both of {window_sizewindow_size_func} are passed.

解决方法

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

  1. tf.contrib.data.group_by_window(
  2. key_func,
  3. reduce_func,
  4. window_size=None,
  5. window_size_func=None
  6. )
  7. batched_dataset = src_tgt_dataset.group_by_window(
  8. key_func=key_func, reduce_func=reduce_func, window_size=batch_size)
  9. 20180626修改此处
  10. batched_dataset = src_tgt_dataset.apply(
  11. tf.contrib.data.group_by_window(
  12. key_func=key_func, reduce_func=reduce_func, window_size=batch_size))

相关文章推荐

tf.contrib.data.group_by_window:https://tensorflow.google.cn/api_docs/python/tf/contrib/data/group_by_window

网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。

本文链接:https://www.xckfsq.com/news/show.html?id=3828
赞同 0
评论 0 条
羞涩踢鞋子L0
粉丝 0 发表 6 + 关注 私信
上周热门
如何使用 StarRocks 管理和优化数据湖中的数据?  2944
【软件正版化】软件正版化工作要点  2863
统信UOS试玩黑神话:悟空  2823
信刻光盘安全隔离与信息交换系统  2717
镜舟科技与中启乘数科技达成战略合作,共筑数据服务新生态  1251
grub引导程序无法找到指定设备和分区  1217
华为全联接大会2024丨软通动力分论坛精彩议程抢先看!  163
点击报名 | 京东2025校招进校行程预告  162
2024海洋能源产业融合发展论坛暨博览会同期活动-海洋能源与数字化智能化论坛成功举办  160
华为纯血鸿蒙正式版9月底见!但Mate 70的内情还得接着挖...  157
本周热议
我的信创开放社区兼职赚钱历程 40
今天你签到了吗? 27
信创开放社区邀请他人注册的具体步骤如下 15
如何玩转信创开放社区—从小白进阶到专家 15
方德桌面操作系统 14
我有15积分有什么用? 13
用抖音玩法闯信创开放社区——用平台宣传企业产品服务 13
如何让你先人一步获得悬赏问题信息?(创作者必看) 12
2024中国信创产业发展大会暨中国信息科技创新与应用博览会 9
中央国家机关政府采购中心:应当将CPU、操作系统符合安全可靠测评要求纳入采购需求 8

加入交流群

请使用微信扫一扫!