Coder Social home page Coder Social logo

Comments (7)

muellerzr avatar muellerzr commented on June 26, 2024

How are you making your databunch?

from fastai_dev.

mrT23 avatar mrT23 commented on June 26, 2024

` def get_y_fun(input):
im_name = os.path.basename(input) # 'staffordshire_bull_terrier_54.jpg'
class_name = im_name[:im_name.rfind('_')]
return class_name

pets = DataBlock(blocks=(ImageBlock, CategoryBlock),
                 get_items=get_image_files,
                 splitter=RandomSplitter(),
                 get_y=get_y_fun)

dbunch = pets.databunch(untar_data(URLs.PETS) / "images", item_tfms=Resize(args.input_size),
                        batch_tfms=aug_transforms(), num_workers=args.num_workers)

`

btw, the regexpr
pat = r'/([^/]+)_\d+.jpg$'
is not cross platform

from fastai_dev.

mrT23 avatar mrT23 commented on June 26, 2024

I did some testing.
this happens in windows, but not in linux.

its a dataloader issue, nowhere in the datalodaer the targets are casted directly to int64

from fastai_dev.

sgugger avatar sgugger commented on June 26, 2024

Are you sure you are using PyTorch 1.3? The type-promotion should get rid of those errors. On Linux, I can do x==y with a tensor of type Int and a tensor of type Long.

from fastai_dev.

sgugger avatar sgugger commented on June 26, 2024

The first error should be fixed now btw.

from fastai_dev.

mrT23 avatar mrT23 commented on June 26, 2024

@sgugger, thanks or the feedback.

Are you sure you are using PyTorch 1.3? The type-promotion should get rid of those errors. On Linux, I can do x==y with a tensor of type Int and a tensor of type Long.

i upgraded my pytorch to 1.3.1 (requirements are currently 1.2.0).
the first problem remains.
i will pull the latest version of fastaiV2 with your commit that fixes the label smoothing,

maybe it is better to explicitly convert the targets to int64 in the collate function?
it is a common practice in some repositories, for examples
https://github.com/NVIDIA/apex/blob/master/examples/imagenet/main_amp.py

def fast_collate(batch):
imgs = [img[0] for img in batch]
targets = torch.tensor([target[1] for target in batch], dtype=torch.int64)

from fastai_dev.

sgugger avatar sgugger commented on June 26, 2024

We don't want to automatically convert to int64 tensors for users because it takes twice the space in GPU memory and sometimes they don't need the int64.

I can't reproduce the error on windows with PyTorch 1.3.1. When asking for the accuracy between a tensor of type Int (int32) and a tensor of type Long (int64), I don't have any error.

from fastai_dev.

Related Issues (20)

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.