I’m trying to update the legacy Python code below but I can’t seem to find the necessary method.
expansion_factor = 100
for j in range(expansion_factor):
for i in range(train_df.shape[0]):
try:
ex = data.Example.fromlist([train_df.qs[i], train_df.sol[i]], fields)
train_example.append(ex)
except:
pass
for i in range(val_df.shape[0]):
try:
ex = data.Example.fromlist([val_df.qs[i], val_df.sol[i]], fields)
val_example.append(ex)
except:
pass
where fields = [(‘Input’, Input),(‘Output’, Output)]
and Input and Output are tokenized values
Your code snippet doesn’t seem to use any PyTorch-specific methods and it looks instead like pandas
code. It’s also unclear what exactly doesn’t work.
Hi @ptrblck thank you!
Please see the more details below
I am importing-
from torchtext.legacy.data import Field, BucketIterator, Iterator
from torchtext.legacy import data
It is using torchtext.legacy for creating the formlist but I dont see similar package in latest version of pytorch , can you please suggest how I can replace data.Example.fromlist ,
I have tried pands datafame like (pd.DataFrame(list(zip(qs[i]) with list but it is not matching what earlier version of pytorch was doing
example
qs[0] - what is the sum of 2+2
sol[0]- 4
I want to create a list where first element will be question and second element in the list is solution
qs sol
what is the sum of 2+2 4
but if I use panda list it is creating char list
w
h
a
t