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

AttributeError: 'DatasetV1Adapter' object has no attribute 'group_by_window'版本兼容问题解决

上一篇:Windows10 彻底删除 Jenkins - 简单可操作版


下一篇:C#正则表达式基础