Thanks, @sgugger ,
I am having another question, I have trained my model, Now I trained as well, Now I need to make predictions,
sents = ["how would you say fly in italian"]
encoded_dicts = tokenizer.encode_plus(
sents, # Sentence to encode.
add_special_tokens = True, # Add '[CLS]' and '[SEP]'
max_length = 64, # Pad & truncate all sentences.
pad_to_max_length = True,
return_attention_mask = True, # Construct attn. masks.
return_tensors = 'pt', # Return pytorch tensors.
)
# Add the encoded sentence to the list.
one_in = encoded_dicts['input_ids'].to(device)
# And its attention mask (simply differentiates padding from non-padding).
atten_in = encoded_dicts['attention_mask'].to(device)
outputs = model(one_in, token_type_ids=None,
attention_mask=atten_in)
logits = outputs[0]
logits = logits.detach().cpu().numpy()
I am using above code to make predictions, How do I know which is my category as I have 151 categories to be predicted, I used LabelEncoder to encode the intent column, so how do I decide which Intent it is?
Colab is here:- Google Colab
I have another question, I was using PyTorch Lightning, so below is the code,
import numpy as np
import pandas as pd
from tqdm import tqdm
import torch
from transformers import BertTokenizer
from torch.utils.data import Dataset, DataLoader
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.callbacks.early_stopping import EarlyStopping
from transformers import BertForSequenceClassification, AdamW, BertConfig
I am getting
ImportError: cannot import name 'TFPreTrainedModel' from 'transformers' (E:\Anaconda\lib\site-packages\transformers\__init__.py)
