AttributeError: 'DatasetV1Adapter' object has no attribute 'group_by_window'版本兼容问题解决
将
grouped_dataset = dataset.group_by_window( key_func=lambda seq: smart_length(tf_rank1_tensor_len(seq), bucket_bounds=bounds), # choose a bucket reduce_func=lambda key, ds: pad_batch(ds, batch_size, padding=padding, padded_shapes=pad_shape), # apply reduce funtion to pad window_size=window_size)
改为:
grouped_dataset = dataset.apply(tf.compat.v1.data.experimental.group_by_window(
key_func=lambda seq: smart_length(tf_rank1_tensor_len(seq), bucket_bounds=bounds), # choose a bucket
reduce_func=lambda key, ds: pad_batch(ds, batch_size, padding=padding, padded_shapes=pad_shape), # apply reduce funtion to pad
window_size=window_size))
即可
参考:https://tensorflow.google.cn/versions/r1.15/api_docs/python/tf/data/experimental/group_by_window