打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

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

成功解决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'这种属性。

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))

相关文章推荐

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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
使用TensorFlow和深度混合学习进行时间序列预测
Word2vec原理浅析及tensorflow实现
tf.data.Dataset.shuffle(buffer
POSIX线程:线程私有数据
Implementing a CNN for Human Activity Recognition in Tensorflow
word2vec之Skip-Gram模型的tensorflow实现
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服