본문 바로가기

Pytorch6

Huggingface "UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor." 처리법 Huggingface에서 주어지는 Imageprocessor class을 사용할 때 간혹 위와 같은 warning문구가 뜨곤 한다. 예를 들어 비디오를 읽어서 전처리를 하는 함수가 있다고 해보자 self.video_processor = VivitImageProcessor.from_pretrained("google/vivit-b-16x2-kinetics400") ... video = read_video_pyav(container=container, indices=indices) #[T, H, W, C] inputs = self.video_processor(list(video), return_tensors="pt")["pixel_values"] #[1, T, C, H, W] 위 블록의 마지막 줄에서 해당 w.. 2024. 3. 13.
HF Trainer 사용 시 collator에 아무것도 들어오지 않는 경우 Huggingface Trainer 사용시, dataset과 collator class을 같이 넘겨준다. 그런데 getitem까지는 잘 데이터가 담기는데, collator의 call 부분을 찍을 시, 아무것도 들어오지 않는 ( [{}, {}, {}] -> bs 3인 경우) 경우가 생겼을 때 -> Trainer에 넘겨주는 training argument 중 remove_unused_columns을 False로 주면 된다. (기본은 True) Trainer 소스 코드에서 아래 함수로 인해 문제가 발생하는 것인데, def _get_collator_with_removed_columns( self, data_collator: Callable, description: Optional[str] = None ) -> .. 2024. 3. 13.
warm up 처음 warm up https://arxiv.org/pdf/1706.02677.pdf 낮은것부터 점차 올라가는 warm up https://arxiv.org/pdf/1812.01187.pdf 반대로 높은것부터 내려오는? 확실하진않음. variance관련 warmup https://arxiv.org/pdf/1908.03265.pdf 기타 https://papers.nips.cc/paper_files/paper/2019/hash/dc6a70712a252123c40d2adba6a11d84-Abstract.html Control Batch Size and Learning Rate to Generalize Well: Theoretical and Empirical Evidence Requests for name c.. 2023. 8. 23.
Concat용 빈 tensor 사이즈만 만들어놓기 Concat용으로 비어있는 tensor 만들기(사이즈 지정) import torch t1 = torch.zeros((0, 3)) print(t1) print(t1.shape) tensor([], size=(0, 3)) 이런식으로 생성된다 2023. 2. 21.