Skip to content

Commit

Permalink
works for cifar
Browse files Browse the repository at this point in the history
  • Loading branch information
mmardani committed May 2, 2022
1 parent 68c0000 commit 941e924
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 3 deletions.
Binary file modified classification/__pycache__/afnonet.cpython-36.pyc
Binary file not shown.
Binary file modified classification/__pycache__/main_afnonet.cpython-36.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion classification/afnonet.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def __init__(self, dim, mlp_ratio=4., drop=0., drop_path=0., act_layer=nn.GELU,

#to be added soon ... @John: pls double check
if args.mixing_type == "afno":
self.filter = AFNO2D(hidden_size=768, num_blocks=8, sparsity_threshold=0.01, hard_thresholding_fraction=1, hidden_size_factor=1)
self.filter = AFNO2D(hidden_size=args.hidden_size, num_blocks=args.fno_blocks, sparsity_threshold=0.01, hard_thresholding_fraction=1, hidden_size_factor=1)
#self.filter = AdaptiveFourierNeuralOperator(dim, h=h, w=w)
elif args.mixing_type == "bfno":
self.filter = BFNO2D(hidden_size=768, num_blocks=8, hard_thresholding_fraction=1)
elif args.mixing_type == "sa":
Expand Down
Binary file added classification/checkpoint_best.pth
Binary file not shown.
5 changes: 3 additions & 2 deletions classification/main_afnonet.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_args_parser():
# Dataset parameters
parser.add_argument('--data-path', default='/datasets01/imagenet_full_size/061417/', type=str,
help='dataset path')
parser.add_argument('--data-set', default='IMNET', choices=['CIFAR', 'IMNET', 'INAT', 'INAT19'],
parser.add_argument('--data-set', default='IMNET', choices=['CIFAR10', 'CIFAR100', 'CARS', 'FLOWERS', 'IMNET'],
type=str, help='Image Net dataset path')
parser.add_argument('--inat-category', default='name',
choices=['kingdom', 'phylum', 'class', 'order', 'supercategory', 'family', 'genus', 'name'],
Expand Down Expand Up @@ -229,6 +229,7 @@ def main(args):
cudnn.benchmark = True

dataset_train, args.nb_classes = build_dataset(is_train=True, args=args)
print('args.nb_classes', args.nb_classes)
dataset_val, _ = build_dataset(is_train=False, args=args)

if True: # args.distributed:
Expand Down Expand Up @@ -283,7 +284,7 @@ def main(args):
print('mix up is not used')

model = AFNONet(
img_size=args.input_size,
img_size=args.input_size, num_classes=args.nb_classes,
patch_size=4, embed_dim=args.hidden_size, depth=args.num_layers, mlp_ratio=4,
norm_layer=partial(nn.LayerNorm, eps=1e-6)
)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 941e924

Please sign in to comment.