DeepMindのPECEIVERIOモデル(https://arxiv.org/abs/2103.03206)のPytorchへの適応。元の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実装では、事前に処理されたモデルが利用可能な次のタスクをカバーしています。
公式のDeepMindリポジトリの俳句チェックポイントは、Pytorchチェックポイントに変換されており、Google-Driveからダウンロードできます。 Pytorchチェックポイントは、「pytorch_checkpoints」フォルダーに配置する必要があります。これにより、サンプルコードが見つけることができます。
カスタムタスク用の新しいPreceiverioを作成するには、PECESIVER_IO/PECESIVER.pyのPECESIVERクラスが使用されます。
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,
"""以下は、マルチモーダルアプリケーションの知覚verioの図です。
入力プリプロセッサーは、生の入力データを取得し、前述の最初の出来事によって照会できるように前処理します。これは、画像からパッチを作成するなどのものです。通常、位置エンコーディングはプレプロセッサによって組み込まれます。プリプロセッサを使用する代わりに、入力を手動で処理することもできます。
いくつかのinput_preprocessorsはperceiver_io/io_processors/preprocessors.pyにあります
出力ポストプロセッサは、知覚機の最終出力を取得し、それを処理して目的の出力形式を取得します。
いくつかのoutput_postprocessorsはperceiver_io/io_processors/postprocessors.pyにあります
OUPUTクエリは、出力を生成するために知覚機の最終的な潜在表現を照会するために使用される機能を作成します。彼らは引数として前処理された入力を取得して、必要に応じてそれを使用できるようにします。また、通常、位置エンコーディングが組み込まれています。
いくつかのoutput_queriesはperceiver_io/output_queries.py ###複数のモダリティを一度に処理するための複数のモダリティ、モダリティからモジュールへのマッピングを備えた辞書を入力_preprocessors、output_postprocessors、output_queriesに使用できます(cuseiver_io/multimodal_ceier.pyを参照)。異なる入力を互いに互換性のあるものにするために、それらはトレーニング可能なパラメーターを使用して同じチャネルサイズにパッドで埋められます。また、入力とは異なる数の出力クエリを使用することも可能です。
@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 }
}