Giter Site home page Giter Site logo

pytorch-tiny-imagenet's Issues

Why the size of validation dataset is 5000 rather than 10,000

"The dataset contains 100,000 images of 200 classes (500 for each class) downsized to 64×64 colored images. Each class has 500 training images, 50 validation images, and 50 test images." https://towardsdatascience.com/pytorch-ignite-classifying-tiny-imagenet-with-efficientnet-e5b1768e5e8f

According to this link, I think the dataset for validation is 10,000, but when I print the dataset it is about 5000.
dataset_sizes = {x: len(image_datasets[x]) for x in ['train', 'val', 'test']}

When I make predictions with the .pth model, I get 1000-sized logits arrays

Hi, hope you're fine

I ran your code and it worked quite well : first run.sh then ResNet18_224.ipynb and finally ResNet18_FineTune.ipynb
I get the path files
The problem I have is that when I load the model weights, and I do y = model_ft(x) on an image from Tiny ImageNet, I get a probabilities/logits array of size 1000, and not 200 as expected.
Here is my code (strongly inspired by yours) :

model_ft = models.resnet18()
model_ft.conv1 = nn.Conv2d(3,64, kernel_size=(3,3), stride=(1,1), padding=(1,1), bias=False)
model_ft.maxpool = nn.Sequential()
model_ft.avgpool = nn.AdaptiveAvgPool2d(1)
model_ft.fc.out_features = 200

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model_ft = model_ft.to(device)

model_ft.load_state_dict(torch.load('./models/finetuned2/model_18_epoch.pt',
                                    map_location=torch.device('cpu')))

path = 'tiny-imagenet-200/val/images/val_2342.JPEG'
x = plt.imread(path)
plt.imshow(x)

x = np.transpose(x, (2, 0, 1))
x.reshape((1, 3, 64, 64))

x = Variable(torch.from_numpy(x))
x = x.float()
x = x.view(1, 3, 64, 64)

model_ft.eval()

y = model_ft(x)
z = y.detach().numpy()

Any help is welcome, thanks a lot.

手动支持一下。

有几个问题想请教一下。

  1. 训练时间。resnet18使用tiny-imagenet数据集训练一轮的时间大概是多久?
  2. 关于预训练权重。如果不使用预训练权重的结果大概是多少呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.