This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 the Regents of the University of California, Nerfstudio Team and contributors. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import typing as t | |
from typing import Union | |
import torch | |
from torch import nn, Tensor | |
from torch.nn import functional as F | |
from torch.nn.common_types import _size_2_t | |
from torch.nn.modules.utils import _pair |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
import matplotlib.pyplot as plt | |
import torch | |
from torch import nn | |
from models.efficientsplitformer.efficientsplitcmtformer2 import _Meta4D, Meta4D, SelfSeparableMeta4D | |
from models.nn.tokenmixer import MultiHeadSelfAttention, _TokenMixer | |
from models.nn.mbblock import MBConv, MBConvAttention |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# script to extract ImageNet dataset | |
# ILSVRC2012_img_train.tar (about 138 GB) | |
# ILSVRC2012_img_val.tar (about 6.3 GB) | |
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory | |
# | |
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md | |
# | |
# train/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo for https://arxiv.org/pdf/1708.00489.pdf and Fig. 3 of https://arxiv.org/pdf/2106.08265.pdf | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from tqdm import tqdm | |
sample_num = 1000 | |
x_sample = np.random.uniform(-1, 1, sample_num) | |
y_sample = np.random.uniform(-1, 1, sample_num) | |
dataset = np.stack([x_sample, y_sample], axis=1) |