Joonas' Note

Joonas' Note

[PyTorch] Tensor, NumPy, Pandas 타입 표 본문

AI

[PyTorch] Tensor, NumPy, Pandas 타입 표

2022. 4. 19. 22:08 joonas

    Pandas는 기본값이 64비트 타입임에 유의해야한다.

    ╔══════════════════════════╦════════════════╦════════════════════╦═════════════════════════╦═════════╦═════════╗
    ║        Data type         ║     dtype      ║     CPU tensor     ║       GPU tensor        ║  NumPy  ║  Pandas ║
    ╠══════════════════════════╬════════════════╬════════════════════╬═════════════════════════╬═════════╣═════════╣
    ║ Boolean                  ║ torch.bool     ║ torch.BoolTensor   ║ torch.cuda.BoolTensor   ║ bool_   ║ bool    ║
    ║ 8-bit integer (unsigned) ║ torch.uint8    ║ torch.ByteTensor   ║ torch.cuda.ByteTensor   ║ uint8   ║ uint8   ║
    ║ 8-bit integer (signed)   ║ torch.int8     ║ torch.CharTensor   ║ torch.cuda.CharTensor   ║ int8    ║ int8    ║
    ║ 16-bit floating point    ║ torch.float16  ║ torch.HalfTensor   ║ torch.cuda.HalfTensor   ║ float16 ║ float16 ║
    ║                          ║ torch.half     ║                    ║                         ║         ║         ║
    ║ 32-bit floating point    ║ torch.float32  ║ torch.FloatTensor  ║ torch.cuda.FloatTensor  ║ float_  ║ float32 ║
    ║                          ║ torch.float    ║                    ║                         ║ float32 ║         ║
    ║ 64-bit floating point    ║ torch.float64  ║ torch.DoubleTensor ║ torch.cuda.DoubleTensor ║ float64 ║ float   ║
    ║                          ║ torch.double   ║                    ║                         ║         ║ float64 ║
    ║ 16-bit integer (signed)  ║ torch.int16    ║ torch.ShortTensor  ║ torch.cuda.ShortTensor  ║ int16   ║ int16   ║
    ║                          ║ torch.short    ║                    ║                         ║         ║         ║
    ║ 32-bit integer (signed)  ║ torch.int32    ║ torch.IntTensor    ║ torch.cuda.IntTensor    ║ int_    ║ int32   ║
    ║                          ║ torch.int      ║                    ║                         ║ int32   ║         ║
    ║ 64-bit integer (signed)  ║ torch.int64    ║ torch.LongTensor   ║ torch.cuda.LongTensor   ║ int64   ║ int     ║
    ║                          ║ torch.long     ║                    ║                         ║         ║ int64   ║
    ╚══════════════════════════╩═════════════════════════════════════╩═════════════════════════╩═══════════════════╝

    링크

     

    torch.Tensor — PyTorch 1.11.0 documentation

    Shortcuts

    pytorch.org

     

     

    pandas.BooleanDtype — pandas 1.4.2 documentation

    Extension dtype for boolean data. Warning BooleanDtype is considered experimental. The implementation and parts of the API may change without warning.

    pandas.pydata.org

     

    RuntimeError: expected scalar type Long but found Float

    I can't get the dtypes to match, either the loss wants long or the model wants float if I change my tensors to long. The shape of the tensors are 42000, 1, 28, 28 and 42000. I'm not sure where I can

    stackoverflow.com

     

    Comments