Thứ Bảy, 11 tháng 9, 2021

python OOP with pytorch

 1. Diplay properties of an object in python (e.g. DataLoader)

ipdb> dir(train_loader.dataset)
['__add__', '__class__', '__class_getitem__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__orig_bases__', '__parameters__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_format_transform_repr', '_is_protocol', '_repr_indent', 'class_to_idx', 'classes', 'extensions', 'extra_repr', 'find_classes', 'imgs', 'loader', 'make_dataset', 'root', 'samples', 'target_transform', 'targets', 'transform', 'transforms']
ipdb> train_loader.dataset.class_to_idx

Here class_to_idx is a nice property of you want to make sure how ImageFolder assigned unique IDs to your human-readable class IDs.

 2. DataLoader is super slow

Even if I load the data manually, the speedup comes to around 10 times. WTHH??

Không có nhận xét nào:

Đăng nhận xét