本文簡要介紹python語言中 torchdata.datapipes.iter.HttpReader
的用法。
用法:
class torchdata.datapipes.iter.HttpReader(source_datapipe: IterDataPipe[str], timeout: Optional[float] = None)
source_datapipe-包含 URL 的 DataPipe
timeout-HTTP 請求超時(以秒為單位)
獲取文件 URL(指向文件的 HTTP URL),並產生文件 URL 和 IO 流的元組。
示例
>>> from torchdata.datapipes.iter import IterableWrapper, HttpReader >>> file_url = "https://raw.githubusercontent.com/pytorch/data/main/LICENSE" >>> http_reader_dp = HttpReader(IterableWrapper([file_url])) >>> reader_dp = http_reader_dp.readlines() >>> it = iter(reader_dp) >>> path, line = next(it) >>> path https://raw.githubusercontent.com/pytorch/data/main/LICENSE >>> line b'BSD 3-Clause License'
參數:
相關用法
- Python PyTorch Header用法及代碼示例
- Python PyTorch Hardsigmoid用法及代碼示例
- Python PyTorch HalfCauchy用法及代碼示例
- Python PyTorch HalfNormal用法及代碼示例
- Python PyTorch HashChecker用法及代碼示例
- Python PyTorch Hardtanh用法及代碼示例
- Python PyTorch Hardshrink用法及代碼示例
- Python PyTorch Hardswish用法及代碼示例
- Python PyTorch HashStore用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
- Python PyTorch positive用法及代碼示例
- Python PyTorch renorm用法及代碼示例
- Python PyTorch AvgPool2d用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch Bernoulli用法及代碼示例
- Python PyTorch Tensor.unflatten用法及代碼示例
- Python PyTorch Sigmoid用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torchdata.datapipes.iter.HttpReader。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。