keras.utils.Sequence
时间: 2024-05-27 10:11:19 浏览: 15
`keras.utils.Sequence` is a Python class that provides an abstraction for working with large datasets that need to be loaded in batches during training. It is a subclass of the `keras.utils.Sequence` class and implements two abstract methods: `__getitem__` and `__len__`.
The `__getitem__` method is responsible for returning a batch of data and labels when given an index. This method is called by the Keras training loop during training.
The `__len__` method returns the total number of batches in the dataset. This method is used by Keras to determine the total number of steps per epoch during training.
`keras.utils.Sequence` is useful when working with large datasets that cannot be loaded into memory all at once. By loading data in batches, it reduces memory usage and allows for faster training.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)