当前位置:网站首页>torch.utils.data.DataLoader()详解【Pytorch入门手册】
torch.utils.data.DataLoader()详解【Pytorch入门手册】
2022-06-10 15:34:00 【K同学啊】
函数原型
DataLoader(dataset, batch_size=1, shuffle=False, sampler=None,
batch_sampler=None, num_workers=0, collate_fn=None,
pin_memory=False, drop_last=False, timeout=0,
worker_init_fn=None, *, prefetch_factor=2,
persistent_workers=False)
功能
根据自定义的格式将数据封装成Tensor。
参数说明
dataset (Dataset)– dataset from which to load the data.
要从中加载数据的数据集。batch_size (int, optional)– how many samples per batch to load (default: 1).
每批次要装载多少样品shuffle (bool, optional)– set to True to have the data reshuffled at every epoch (default: False).
设置为True以使数据在每个时期都重新洗牌sampler (Sampler or Iterable, optional)– defines the strategy to draw samples from the dataset. Can be any Iterable with len implemented. If specified, shuffle must not be specified.
定义从数据集中抽取样本的策略batch_sampler (Sampler or Iterable, optional)– like sampler, but returns a batch of indices at a time. Mutually exclusive with batch_size, shuffle, sampler, and drop_last.
类似于采样器,但一次返回一批索引。 与batch_size,shuffle,sampler和drop_last互斥。num_workers (int, optional)– how many subprocesses to use for data loading. 0 means that the data will be loaded in the main process. (default: 0)
多少个子流程用于数据加载。 0表示将在主进程中加载数据。 (默认值:0)collate_fn (callable, optional)– merges a list of samples to form a mini-batch of Tensor(s). Used when using batched loading from a map-style dataset.
合并样本列表以形成张量的小批量。pin_memory (bool, optional)– If True, the data loader will copy Tensors into CUDA pinned memory before returning them. If your data elements are a custom type, or your collate_fn returns a batch that is a custom type.
如果为True,则数据加载器在将张量返回之前将其复制到CUDA固定的内存中。 如果您的数据元素是自定义类型,或者您的collate_fn返回的是一个自定义类型的批处理drop_last (bool, optional)– set to True to drop the last incomplete batch, if the dataset size is not divisible by the batch size. If False and the size of dataset is not divisible by the batch size, then the last batch will be smaller. (default: False)
如果数据集大小不能被批量大小整除,则设置为True以删除最后一个不完整的批量。 如果为False并且数据集的大小不能被批次大小整除,则最后一批将较小。timeout (numeric, optional)– if positive, the timeout value for collecting a batch from workers. Should always be non-negative. (default: 0)
如果为正,则为从工作人员收集批次的超时值。 应始终为非负数。 (默认值:0)worker_init_fn (callable, optional)– If not None, this will be called on each worker subprocess with the worker id (an int in [0, num_workers - 1]) as input, after seeding and before data loading. (default: None)prefetch_factor (int, optional, keyword-only arg)– Number of samples loaded in advance by each worker. 2 means there will be a total of 2 * num_workers samples prefetched across all workers. (default: 2)
每个子流程预先加载的样本数。 2表示将在所有子流程中预取总共2 * num_workers个样本。 (默认值:2)persistent_workers (bool, optional)– If True, the data loader will not shutdown the worker processes after a dataset has been consumed once. This allows to maintain the workers Dataset instances alive. (default: False)
如果为True,则一次使用数据集后,数据加载器将不会关闭工作进程。 这样可以使Worker Dataset实例保持活动状态。 (默认值:False)
🦪 实战案例
边栏推荐
- You will never want to miss these vertical niche navigation websites
- [object].
- 统一认证中心 Oauth2 认证坑
- HKU and NVIDIA | factuality enhanced language models for open ended text generation
- C# 游戏雏形 人物地图双重移动
- 2290. Minimum Obstacle Removal to Reach Corner
- Even some people say that ArrayList is twice as large. Today, I will take you to tear up the ArrayList source code
- Applet warning: now you can provide attr `wx:key` for a `wx:for` to improve performance
- What has guanghetong done in the three years of 5g business from "seeding in the first generation" to "flower on the ground"?
- ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解0——整体框架与理论基础知识
猜你喜欢

this和对象原型

HKU and NVIDIA | factuality enhanced language models for open ended text generation

ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解1——IMU流型预积分

姿态估计之2D人体姿态估计 - (OpenPose) Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields

MapReduce之分区案例的代码实现

Vins theory and code explanation 4 - initialization

反“内卷”,消息称 360 企业安全云将上线“一键强制下班”功能,电脑自动关闭办公软件

排序与分页

ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 3 - tight coupling optimization model

ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解0——整体框架与理论基础知识
随机推荐
Anba cv2fs/cv22fs obtained ASIL C chip function safety certification, surpassing the level of similar chips in the market
农产品期货如何开户?有没有什么资金条件?
排名前十、手续费低的期货公司有哪些?安全吗
Sorting and paging
Cube 技术解读 | Cube 渲染设计的前世今生
ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解2——IMU初始化
ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 3 - tight coupling optimization model
Guanghetong cooperates with China Mobile, HP, MediaTek and Intel to build 5g fully connected PC pan terminal products
Save a window with a specific size, resolution, or background color
VINS理论与代码详解4——初始化
安霸CV2FS/CV22FS获得ASIL C芯片功能安全认证,超越市场同类芯片水平
Hutool Usage Summary (VIP collection version)
Wechat applet color gradient
Digital management medium + low code, jnpf opens a new engine for enterprise digital transformation
json. Load (s) and json dump(s)
Apple style Chinese: it seems to express the meaning clearly, and the Apple style propaganda copy that you don't fully understand
MapReduce之Reduce阶段的join操作案例
uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
硬件仪器的使用
How the terminator sets the font to display different colors