Pytorch Equivalent

Hi i am new to Deep learning.

I am trying to convert a Keras code into pytorch just wanted to understand what are pytorch equivalent for the following 4 lines of code.

from tensorflow.keras.layers import Embedding, LSTM, Dense
from tensorflow.keras.models import Model
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences

for

  1. from tensorflow.keras.layers import Embedding, LSTM, Dense

i am trying:

from torch.nn import Embedding, LSTM, Linear

  1. from tensorflow.keras.preprocessing.text import Tokenizer
    i am trying:
    from torchtext.data import get_tokenizer

  2. from tensorflow.keras.preprocessing.sequence import pad_sequences
    i am thinking
    from torch.nn.utils.rnn import pad_sequence

  3. from tensorflow.keras.models import Model

could not figure out anything for this

the original code i am trying to convert is mentioned here:

I could be wrong, I have never used keras but for what I know there is not a precise mapping between keras (that has a high-level abstraction) and pytorch.

The thing most similar to keras.Model, I think it is nn.Module but I am not sure.

Let’s wait for someone else more expert than me :slight_smile: