日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2025/3/21 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 成功解决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:

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

?

?

?

相關文章推薦

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

總結

以上是生活随笔為你收集整理的成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。