Pytorch Equivalent

manish-tripathi: <p>Hi i am new to Deep learning.</p>
<p>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.</p>
<pre><code class="lang-auto">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
</code></pre>
<p>for</p>
<ol>
<li><code>from tensorflow.keras.layers import Embedding, LSTM, Dense</code></li>
</ol>
<p>i am trying:</p>
<p><code>from torch.nn import Embedding, LSTM, Linear</code></p>
<ol start="2">
<li>
<p><code>from tensorflow.keras.preprocessing.text import Tokenizer</code><br>
i am trying:<br>
<code>from torchtext.data import get_tokenizer</code></p>
</li>
<li>
<p><code>from tensorflow.keras.preprocessing.sequence import pad_sequences</code><br>
i am thinking<br>
<code>from torch.nn.utils.rnn import pad_sequence</code></p>
</li>
<li>
<p><code>from tensorflow.keras.models import Model</code></p>
</li>
</ol>
<p><strong>could not figure out anything for this</strong></p>
<p>the original code i am trying to convert is mentioned here:</p>
<aside class="onebox githubblob" data-onebox-src="https://github.com/sunilbelde/neural-machine-translation-english-to-hindi-telugu/blob/main/NeuralMachineTranslation_eng_hindi.ipynb">
  <header class="source">

      <a href="https://github.com/sunilbelde/neural-machine-translation-english-to-hindi-telugu/blob/main/NeuralMachineTranslation_eng_hindi.ipynb" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/sunilbelde/neural-machine-translation-english-to-hindi-telugu/blob/main/NeuralMachineTranslation_eng_hindi.ipynb" target="_blank" rel="noopener nofollow ugc">sunilbelde/neural-machine-translation-english-to-hindi-telugu/blob/main/NeuralMachineTranslation_eng_hindi.ipynb</a></h4>


    <pre><code class="lang-ipynb">{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "NeuralMachineTranslation_eng_hindi.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
</code></pre>


  This file has been truncated. <a href="https://github.com/sunilbelde/neural-machine-translation-english-to-hindi-telugu/blob/main/NeuralMachineTranslation_eng_hindi.ipynb" target="_blank" rel="noopener nofollow ugc">show original</a>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


valgi0: <p>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.</p>
<p>The thing most similar to keras.Model, I think it is nn.Module but I am not sure.</p>
<p>Let’s wait for someone else more expert than me <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=10" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>