votes up 4

Unable to convert output to PyTorch tensors format, PyTorch is not installed.

Package:
Exception Class:
ImportError

Raise code

                )
            import tensorflow as tf

            as_tensor = tf.constant
            is_tensor = tf.is_tensor
        elif tensor_type == TensorType.PYTORCH:
            if not is_torch_available():
                raise ImportError("Unable to convert output to PyTorch tensors format, PyTorch is not installed.")
            import torch

            as_tensor = torch.tensor
            is_tensor = torch.is_tensor
        elif tensor_type == TensorType.JAX:
            if not is_flax_available():
                raise ImportError("Unable to convert output to JAX tensors format, JAX is not installed.")
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 0 votes down

Error code:

from transformers import BatchEncoding

data = {"inputs": [[123], [456]], "labels": [01]}

encod = BatchEncoding(data)

ec = encod.convert_to_tensors('pt')
print(ec)

Fix version:

Make sure you have installed Torch

pip install torch
Jul 16, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix