SNNMLP

import torch
model = torch.hub.load('huawei-noah/Efficient-AI-Backbones', 'snnmlp_t', pretrained=True)
# or
# model = torch.hub.load('huawei-noah/Efficient-AI-Backbones', 'snnmlp_s', pretrained=True)
# or
# model = torch.hub.load('huawei-noah/Efficient-AI-Backbones', 'snnmlp_b', pretrained=True)
model.eval()

所有預訓練模型都要求輸入影像以相同的方式進行歸一化,即由形狀為 (3 x H x W) 的 3 通道 RGB 影像組成的小批次資料,其中 HW 預計至少為 224。影像必須載入到 [0, 1] 範圍內,然後使用 mean = [0.485, 0.456, 0.406]std = [0.229, 0.224, 0.225] 進行歸一化。

這是一個示例執行。

# Download an example image from the pytorch website
import urllib
url, filename = ("https://github.com/pytorch/hub/raw/master/dog.jpg", "dog.jpg")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
# sample execution (requires torchvision)
from PIL import Image
from torchvision import transforms
input_image = Image.open(filename)
preprocess = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(input_image)
input_batch = input_tensor.unsqueeze(0) # create a mini-batch as expected by the model

# move the input and model to GPU for speed if available
if torch.cuda.is_available():
    input_batch = input_batch.to('cuda')
    model.to('cuda')

with torch.no_grad():
    output = model(input_batch)
# Tensor of shape 1000, with confidence scores over ImageNet's 1000 classes
print(output[0])
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
print(torch.nn.functional.softmax(output[0], dim=0))

模型描述

SNNMLP 將 LIF 神經元機制整合到 MLP 模型中,以在不增加額外 FLOPs 的情況下實現更高的準確性。我們提出了一種全精度 LIF 操作,用於在補丁之間進行通訊,包括不同方向的水平 LIF 和垂直 LIF。我們還建議使用組 LIF 來提取更好的區域性特徵。藉助 LIF 模組,我們的 SNNMLP 模型在 ImageNet 資料集上分別以僅 4.4G、8.5G 和 15.2G FLOPs 實現了 81.9%、83.3% 和 83.6% 的 Top-1 準確率。

以下列出了預訓練模型在 ImageNet 資料集上的相應準確率。

模型結構#引數FLOPsTop-1 準確率
SNNMLP Tiny28M4.4G81.88
SNNMLP Small50M8.5G83.30
SNNMLP Base88M15.2G85.59

參考文獻

您可以在此處閱讀完整論文。

@inproceedings{li2022brain,
  title={Brain-inspired multilayer perceptron with spiking neurons},
  author={Li, Wenshuo and Chen, Hanting and Guo, Jianyuan and Zhang, Ziyang and Wang, Yunhe},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={783--793},
  year={2022}
}

受大腦啟發的、帶有脈衝神經元的多層感知器

模型型別: 可指令碼化 | 視覺
提交者: 華為諾亞方舟實驗室