Pytorch에 DeepMind의 Perceiverio 모델 (https://arxiv.org/abs/2103.03206)의 적응. 원래 Jax/Haiku 코드는 여기에서 찾을 수 있습니다 : https://github.com/deepmind/deepmind-research/tree/master/perceiver
git clone https://github.com/JOBR0/PerceiverIO_Pytorch
cd PerceiverIO_Pytorchpython3 -m venv perceiverEnv
source perceiverEnv/bin/activate공식 지침에 따라 pytorch 설치 : https://pytorch.org/get-started/locally/
요구 사항에서 다른 필수 패키지를 설치합니다 .txt :
pip3 install -r requirements.txt구현은 사전 각인 모델을 사용할 수있는 다음 예제 작업을 다룹니다.
공식 심해 리포지토리의 Haiku 검문소는 Pytorch 체크 포인트로 변환되었으며 Google-Drive에서 다운로드 할 수 있습니다. Pytorch 체크 포인트는 예제 코드에서 찾을 수 있도록 'pytorch_checkpoints'폴더에 배치해야합니다.
사용자 정의 작업을위한 새로운 preceiverio를 만들려면 perceiver_io/perceiver.py의 perceiver 클래스가 사용됩니다.
class PerceiverIO ( nn . Module ):
"""The Perceiver: a scalable, fully attentional architecture.
Args:
num_blocks (int): Number of times the block is applied with shared weights. Default: 8
num_self_attends_per_block (int): Number of self-attentions in the block. Default: 6,
num_latents: (int): Number of latent vectors. Default 512,
num_latent_channels (int): Number of channels for the latent vectors. Default: 1024,
final_project (bool): Whether to apply a linear layer to the outputs before the post-processors. Default: True,
final_project_out_channels (int): Number of output channels for the final projection layer. Default: None,
perceiver_encoder_kwargs (Dict): Additional arguments for the perceiver encoder class. Default: {},
perceiver_decoder_kwargs (Dict): Additional arguments for the perceiver decoder class. Default: {},
input_preprocessors (dict / nn.Module): Optional input preprocessors. 1 or none for each modality. Default: None,
output_postprocessors (dict / nn.Module): Optional output postprocessors. 1 or none for each modality. Default: None,
output_queries (dict / nn.Module): Modules that create the output queries. 1 for each modality. Default: None,
output_query_padding_channels (int): Number of learnable features channels that are added to the output queries. Default: 0,
input_padding_channels (int): Number of learnable features channels that are added to the preprocessed inputs. Default: 0,
input_channels (dict, int): = The number of input channels need to be specified if NO preprocessor is used. Otherwise,
the number will be inferred from the preprocessor. Default: None,
input_mask_probs (dict): Probability with which each input modality will be masked out. Default None,
"""다음은 멀티 모달 응용 프로그램에 대한 Perceiverio의 다이어그램입니다.
입력 전처리 기는 원시 입력 데이터를 가져 와서 첫 번째 교차 출석으로 쿼리 할 수 있도록 전제 처리합니다. 이것은 이미지에서 패치를 만드는 것과 같은 것일 수 있습니다. 일반적으로 위치 인코딩은 사전 처리기에 의해 통합됩니다. 전처리기를 사용하는 대신 입력을 수동으로 처리 할 수도 있습니다.
여러 Input_preprocessors는 perceiver_io/io_processors/preprocessors.py 에서 찾을 수 있습니다
출력 후 프로세서는 인식 자의 최종 출력을 취하고 원하는 출력 형식을 얻기 위해 처리합니다.
여러 output_postprocessors는 perceiver_io/io_processors/postprocessors.py 에서 찾을 수 있습니다
OUPUT 쿼리는 출력을 생성하기 위해 인식 자의 최종 잠재적 표현을 쿼리하는 데 사용되는 기능을 만듭니다. 그들은 사전 처리 된 입력을 인수로 얻으므로 원하는 경우 사용할 수 있습니다. 또한 일반적으로 위치 인코딩을 포함합니다.
몇 가지 Output_Queries는 perceiver_io/output_queries.py ### 한 번에 여러 양식을 처리하기위한 여러 가지 양식에서 찾을 수 있습니다. 모듈에서 모듈로의 매핑이있는 사전은 input_preprocessors, output_postpocessors 및 output_queries (perceiver_io/multimodal_perceover. 서로 다른 입력을 서로 호환시키기 위해 훈련 가능한 매개 변수로 동일한 채널 크기로 패딩됩니다. 입력이 제공되는 것과는 다른 수의 출력 쿼리를 사용할 수도 있습니다.
@misc { jaegle2021perceiver ,
title = { Perceiver IO: A General Architecture for Structured Inputs & Outputs } ,
author = { Andrew Jaegle and Sebastian Borgeaud and Jean-Baptiste Alayrac and Carl Doersch and Catalin Ionescu and David Ding and Skanda Koppula and Andrew Brock and Evan Shelhamer and Olivier Hénaff and Matthew M. Botvinick and Andrew Zisserman and Oriol Vinyals and João Carreira } ,
year = { 2021 } ,
eprint = { 2107.14795 } ,
archivePrefix = { arXiv } ,
primaryClass = { cs.LG }
}