indicate 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Train.ipynb","provenance":[],"collapsed_sections":[],"machine_shape":"hm","mount_file_id":"1-LZQOcJOXLo2BrDMK8kOPPnv7Vfoj-ut","authorship_tag":"ABX9TyOVwc0pEqtd8WN5JAQDcd68"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"BUvulILrqtkf","executionInfo":{"status":"ok","timestamp":1639593433986,"user_tz":480,"elapsed":3191,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"08853913-2b11-46eb-b10d-3d4720a8ae1f"},"outputs":[{"output_type":"stream","name":"stdout","text":["Requirement already satisfied: tensorflow_addons in /usr/local/lib/python3.7/dist-packages (0.15.0)\n","Requirement already satisfied: typeguard>=2.7 in /usr/local/lib/python3.7/dist-packages (from tensorflow_addons) (2.7.1)\n"]}],"source":["pip install tensorflow_addons"]},{"cell_type":"code","source":["%cd /content/drive/MyDrive/Colab/Transliterate/Main"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"X3542qmUrVqO","executionInfo":{"status":"ok","timestamp":1639593433988,"user_tz":480,"elapsed":8,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"c22d9e99-7d0d-483d-dd8c-cbb463e62054"},"execution_count":2,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/drive/MyDrive/Colab/Transliterate/Main\n"]}]},{"cell_type":"code","source":["import json\n","import os\n","import time\n","\n","import pandas as pd\n","import tensorflow as tf\n","import tensorflow_addons as tfa\n","\n","from sklearn.model_selection import train_test_split\n","\n","from encoder import Encoder\n","from decoder import Decoder"],"metadata":{"id":"1wHPGoNrrd2s","executionInfo":{"status":"ok","timestamp":1639593436715,"user_tz":480,"elapsed":2732,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":3,"outputs":[]},{"cell_type":"code","source":["print(tf.__version__)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"CKh1Ecloa9Pz","executionInfo":{"status":"ok","timestamp":1639593436716,"user_tz":480,"elapsed":18,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"6cf81dab-0ada-4ad5-ef2d-5b719d795214"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["2.7.0\n"]}]},{"cell_type":"markdown","source":["# Load Dataset"],"metadata":{"id":"a1wzzI6zrsQa"}},{"cell_type":"code","source":["input_target_df = pd.read_csv('./data/merged_hi_to_en.csv')"],"metadata":{"id":"63PtIy_-rGtN","executionInfo":{"status":"ok","timestamp":1639593436716,"user_tz":480,"elapsed":15,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":5,"outputs":[]},{"cell_type":"markdown","source":["# Prepare Data for training"],"metadata":{"id":"jLfWz0d0ryHu"}},{"cell_type":"markdown","source":["## Append start and end of sequence for target"],"metadata":{"id":"RbXARDGdsByb"}},{"cell_type":"code","source":["# append start and end of sequence for target\n","sos = '^'\n","eos = '$'\n","\n","input_target_df['english'] = sos + input_target_df['english'].astype(str) + eos"],"metadata":{"id":"lqEt-Smdrxas","executionInfo":{"status":"ok","timestamp":1639593436932,"user_tz":480,"elapsed":11,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":6,"outputs":[]},{"cell_type":"code","source":["input_target_df.head()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":206},"id":"7SH3SP1Xsbp1","executionInfo":{"status":"ok","timestamp":1639593436933,"user_tz":480,"elapsed":12,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"7196d6e6-8bae-496f-c25d-db5fc107bc58"},"execution_count":7,"outputs":[{"output_type":"execute_result","data":{"text/html":["<div>\n","<style scoped>\n"," .dataframe tbody tr th:only-of-type {\n"," vertical-align: middle;\n"," }\n","\n"," .dataframe tbody tr th {\n"," vertical-align: top;\n"," }\n","\n"," .dataframe thead th {\n"," text-align: right;\n"," }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n"," <thead>\n"," <tr style=\"text-align: right;\">\n"," <th></th>\n"," <th>hindi</th>\n"," <th>english</th>\n"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n"," <th>0</th>\n"," <td>प्रयात सुबोध चन्द्र दास</td>\n"," <td>^late subodh chandra das$</td>\n"," </tr>\n"," <tr>\n"," <th>1</th>\n"," <td>स्वर्गीय पिनाकि कुंडू</td>\n"," <td>^late pinaki kundu$</td>\n"," </tr>\n"," <tr>\n"," <th>2</th>\n"," <td>मृत नूर महम्मद बिश्वास</td>\n"," <td>^late nur mohammad biswas$</td>\n"," </tr>\n"," <tr>\n"," <th>3</th>\n"," <td>नारायण चंद्र डॉं</td>\n"," <td>^narayan chandra dawn$</td>\n"," </tr>\n"," <tr>\n"," <th>4</th>\n"," <td>आब्दुल मन्नान</td>\n"," <td>^abdul mannan$</td>\n"," </tr>\n"," </tbody>\n","</table>\n","</div>"],"text/plain":[" hindi english\n","0 प्रयात सुबोध चन्द्र दास ^late subodh chandra das$\n","1 स्वर्गीय पिनाकि कुंडू ^late pinaki kundu$\n","2 मृत नूर महम्मद बिश्वास ^late nur mohammad biswas$\n","3 नारायण चंद्र डॉं ^narayan chandra dawn$\n","4 आब्दुल मन्नान ^abdul mannan$"]},"metadata":{},"execution_count":7}]},{"cell_type":"markdown","source":["## Construct Vocab for Source and Target"],"metadata":{"id":"LobqH0_ysdXj"}},{"cell_type":"code","source":["input_words = input_target_df['hindi'].tolist()\n","target_words = input_target_df['english'].tolist()"],"metadata":{"id":"-dRUCb3dsLn_","executionInfo":{"status":"ok","timestamp":1639593436934,"user_tz":480,"elapsed":12,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":8,"outputs":[]},{"cell_type":"code","source":["print(f\"Total number of input words {len(input_words)}\")\n","print(f\"Total number of target words {len(target_words)}\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"u0_y53xksY4Y","executionInfo":{"status":"ok","timestamp":1639593436934,"user_tz":480,"elapsed":12,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"74cb6877-67fc-4358-f8e9-8f94566d4372"},"execution_count":9,"outputs":[{"output_type":"stream","name":"stdout","text":["Total number of input words 116021\n","Total number of target words 116021\n"]}]},{"cell_type":"code","source":["input_lang_tokenizer = tf.keras.preprocessing.text.Tokenizer(filters='', char_level=True)\n","input_lang_tokenizer.fit_on_texts(input_words)\n","input_tensor = input_lang_tokenizer.texts_to_sequences(input_words)\n","input_tensor = tf.keras.preprocessing.sequence.pad_sequences(input_tensor, padding='post')"],"metadata":{"id":"zKIjiRn_suXm","executionInfo":{"status":"ok","timestamp":1639593438614,"user_tz":480,"elapsed":1688,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":10,"outputs":[]},{"cell_type":"code","source":["target_lang_tokenizer = tf.keras.preprocessing.text.Tokenizer(filters='', char_level=True)\n","target_lang_tokenizer.fit_on_texts(target_words)\n","target_tensor = target_lang_tokenizer.texts_to_sequences(target_words)\n","target_tensor = tf.keras.preprocessing.sequence.pad_sequences(target_tensor, padding='post')"],"metadata":{"id":"GAUAkBKZs_B8","executionInfo":{"status":"ok","timestamp":1639593440137,"user_tz":480,"elapsed":1527,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":11,"outputs":[]},{"cell_type":"markdown","source":["## Save Vocab for Source and Target"],"metadata":{"id":"xbx21xm5tKG0"}},{"cell_type":"code","source":["# save tokenizers\n","hindi_tokenizer_json = input_lang_tokenizer.to_json()\n","with open('hindi_tokens.json', 'w') as f:\n"," json.dump(hindi_tokenizer_json, f)\n","\n","english_tokenizer_json = target_lang_tokenizer.to_json()\n","with open('english_tokens.json', 'w') as f:\n"," json.dump(english_tokenizer_json, f)"],"metadata":{"id":"N_tEU-mctE64","executionInfo":{"status":"ok","timestamp":1639593440137,"user_tz":480,"elapsed":5,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":12,"outputs":[]},{"cell_type":"markdown","source":["## Split data into Train and Validation"],"metadata":{"id":"YP6tOVP_tglo"}},{"cell_type":"code","source":["# split train and validation\n","input_tensor_train, input_tensor_val, target_tensor_train, target_tensor_val = train_test_split(input_tensor, target_tensor, test_size=0.2)"],"metadata":{"id":"XuednRVRtVPW","executionInfo":{"status":"ok","timestamp":1639593440138,"user_tz":480,"elapsed":5,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":13,"outputs":[]},{"cell_type":"code","source":["BATCH_SIZE = 64\n","BUFFER_SIZE = 120000\n","\n","train_dataset = tf.data.Dataset.from_tensor_slices((input_tensor_train, target_tensor_train))\n","train_dataset = train_dataset.shuffle(BUFFER_SIZE).batch(BATCH_SIZE, drop_remainder=True)\n","\n","val_dataset = tf.data.Dataset.from_tensor_slices((input_tensor_val, target_tensor_val))\n","val_dataset = val_dataset.batch(BATCH_SIZE, drop_remainder=True)"],"metadata":{"id":"8euCEPBKtxrI","executionInfo":{"status":"ok","timestamp":1639593441270,"user_tz":480,"elapsed":1137,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":14,"outputs":[]},{"cell_type":"code","source":["example_input_batch, example_target_batch = next(iter(train_dataset))\n","example_input_batch.shape, example_target_batch.shape"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ecn7UTUAt5dX","executionInfo":{"status":"ok","timestamp":1639593441271,"user_tz":480,"elapsed":11,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"61abc46e-c3ef-44de-b000-5a54cf91ea19"},"execution_count":15,"outputs":[{"output_type":"execute_result","data":{"text/plain":["(TensorShape([64, 47]), TensorShape([64, 49]))"]},"metadata":{},"execution_count":15}]},{"cell_type":"markdown","source":["## Summary of prepared dataset"],"metadata":{"id":"BncLpNAEuWP7"}},{"cell_type":"code","source":["vocab_inp_size = len(input_lang_tokenizer.word_index)+1\n","vocab_tar_size = len(target_lang_tokenizer.word_index)+1\n","\n","max_length_input = input_tensor.shape[1]\n","max_length_output = target_tensor.shape[1]\n","\n","embedding_dim = 256\n","units = 1024\n","steps_per_epoch = input_tensor.shape[0]//BATCH_SIZE"],"metadata":{"id":"7UzIiLwTuG3h","executionInfo":{"status":"ok","timestamp":1639593441271,"user_tz":480,"elapsed":10,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":16,"outputs":[]},{"cell_type":"code","source":["print('Number of samples:', len(input_words))\n","\n","print('Input Vocab size:', vocab_inp_size)\n","print('Target Vocab size:', vocab_tar_size)\n","\n","print('Max sequence length for inputs:', max_length_input)\n","print('Max sequence length for outputs:', max_length_output)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"W3NgN0bRuhWQ","executionInfo":{"status":"ok","timestamp":1639593441272,"user_tz":480,"elapsed":9,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"9216e09f-e20d-4f0a-e92c-666a8fe696b2"},"execution_count":17,"outputs":[{"output_type":"stream","name":"stdout","text":["Number of samples: 116021\n","Input Vocab size: 166\n","Target Vocab size: 36\n","Max sequence length for inputs: 47\n","Max sequence length for outputs: 49\n"]}]},{"cell_type":"markdown","source":["# Encoder"],"metadata":{"id":"Qr9di8mBupTC"}},{"cell_type":"code","source":["encoder = Encoder(vocab_inp_size, embedding_dim, units, BATCH_SIZE)"],"metadata":{"id":"_jOmoDVEutZJ","executionInfo":{"status":"ok","timestamp":1639593441272,"user_tz":480,"elapsed":7,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":18,"outputs":[]},{"cell_type":"markdown","source":["## Test Encoder"],"metadata":{"id":"zxMmclrzuyJw"}},{"cell_type":"code","source":["## Test Encoder Stack\n","# sample input\n","sample_hidden = encoder.initialize_hidden_state()\n","sample_output, sample_h, sample_c = encoder(example_input_batch, sample_hidden)\n","print ('Encoder output shape: (batch size, sequence length, units) {}'.format(sample_output.shape))\n","print ('Encoder h vecotr shape: (batch size, units) {}'.format(sample_h.shape))\n","print ('Encoder c vector shape: (batch size, units) {}'.format(sample_c.shape))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"qlNRs98cuxdp","executionInfo":{"status":"ok","timestamp":1639593441843,"user_tz":480,"elapsed":577,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"48b75d16-53e4-4244-f71c-7b930127f205"},"execution_count":19,"outputs":[{"output_type":"stream","name":"stdout","text":["Encoder output shape: (batch size, sequence length, units) (64, 47, 1024)\n","Encoder h vecotr shape: (batch size, units) (64, 1024)\n","Encoder c vector shape: (batch size, units) (64, 1024)\n"]}]},{"cell_type":"markdown","source":["# Decoder"],"metadata":{"id":"Qw4ebubBu7MW"}},{"cell_type":"code","source":["decoder = Decoder(vocab_tar_size, embedding_dim, units, BATCH_SIZE, \n"," max_length_input, max_length_output, 'luong')"],"metadata":{"id":"EFLPrhRVu9hK","executionInfo":{"status":"ok","timestamp":1639593441844,"user_tz":480,"elapsed":4,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":20,"outputs":[]},{"cell_type":"markdown","source":["## Test Decoder"],"metadata":{"id":"-bDN2S0TvEIT"}},{"cell_type":"code","source":["# Test decoder stack\n","sample_x = tf.random.uniform((BATCH_SIZE, max_length_output))\n","decoder.attention_mechanism.setup_memory(sample_output)\n","initial_state = decoder.build_initial_state(BATCH_SIZE, [sample_h, sample_c], tf.float32)\n","\n","sample_decoder_outputs = decoder(sample_x, initial_state)\n","\n","print(\"Decoder Outputs Shape: \", sample_decoder_outputs.rnn_output.shape)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"pTNciGVdvCzs","executionInfo":{"status":"ok","timestamp":1639593443285,"user_tz":480,"elapsed":1445,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"84302f49-7d8d-4922-d755-420ecbb2435e"},"execution_count":21,"outputs":[{"output_type":"stream","name":"stdout","text":["Decoder Outputs Shape: (64, 48, 36)\n"]}]},{"cell_type":"markdown","source":["# Optimizer and Loss Function"],"metadata":{"id":"Xh07QJ3AwEkV"}},{"cell_type":"code","source":["optimizer = tf.keras.optimizers.Adam()\n","\n","def loss_function(real, pred):\n"," # real shape = (BATCH_SIZE, max_length_output)\n"," # pred shape = (BATCH_SIZE, max_length_output, tar_vocab_size )\n"," cross_entropy = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True, reduction='none')\n"," loss = cross_entropy(y_true=real, y_pred=pred)\n"," mask = tf.logical_not(tf.math.equal(real,0)) #output 0 for y=0 else output 1\n"," mask = tf.cast(mask, dtype=loss.dtype) \n"," loss = mask* loss\n"," loss = tf.reduce_mean(loss)\n"," return loss "],"metadata":{"id":"GAN_YevuwH9X","executionInfo":{"status":"ok","timestamp":1639593443285,"user_tz":480,"elapsed":6,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":22,"outputs":[]},{"cell_type":"markdown","source":["# Checkpoints"],"metadata":{"id":"n04SWU2lwMAo"}},{"cell_type":"code","source":["checkpoint_dir = './data/training_checkpoints'\n","checkpoint_prefix = os.path.join(checkpoint_dir, \"ckpt\")\n","checkpoint = tf.train.Checkpoint(optimizer=optimizer,\n"," encoder=encoder,\n"," decoder=decoder)"],"metadata":{"id":"-RchUEMMwLTt","executionInfo":{"status":"ok","timestamp":1639593443286,"user_tz":480,"elapsed":6,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":23,"outputs":[]},{"cell_type":"markdown","source":["# One train_step operations"],"metadata":{"id":"kn92tVRdcvb1"}},{"cell_type":"code","source":["@tf.function\n","def train_step(inp, targ, enc_hidden):\n"," loss = 0\n","\n"," with tf.GradientTape() as tape:\n"," enc_output, enc_h, enc_c = encoder(inp, enc_hidden)\n","\n","\n"," dec_input = targ[ : , :-1 ] # Ignore <end> token\n"," real = targ[ : , 1: ] # ignore <start> token\n","\n"," # Set the AttentionMechanism object with encoder_outputs\n"," decoder.attention_mechanism.setup_memory(enc_output)\n","\n"," # Create AttentionWrapperState as initial_state for decoder\n"," decoder_initial_state = decoder.build_initial_state(BATCH_SIZE, [enc_h, enc_c], tf.float32)\n"," pred = decoder(dec_input, decoder_initial_state)\n"," logits = pred.rnn_output\n"," loss = loss_function(real, logits)\n","\n"," variables = encoder.trainable_variables + decoder.trainable_variables\n"," gradients = tape.gradient(loss, variables)\n"," optimizer.apply_gradients(zip(gradients, variables))\n","\n"," return loss"],"metadata":{"id":"Z4wTBov2c1Sr","executionInfo":{"status":"ok","timestamp":1639593443286,"user_tz":480,"elapsed":5,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}}},"execution_count":24,"outputs":[]},{"cell_type":"markdown","source":["# Train"],"metadata":{"id":"Jv13BMMfc5rB"}},{"cell_type":"code","source":["EPOCHS = 25\n","\n","best_loss = 1\n","for epoch in range(EPOCHS):\n"," start = time.time()\n","\n"," enc_hidden = encoder.initialize_hidden_state()\n"," total_loss = 0\n"," # print(enc_hidden[0].shape, enc_hidden[1].shape)\n"," for (batch, (inp, targ)) in enumerate(train_dataset.take(steps_per_epoch)):\n"," batch_loss = train_step(inp, targ, enc_hidden)\n"," total_loss += batch_loss\n","\n"," if batch % 100 == 0:\n"," print('Epoch {} Batch {} Loss {:.4f}'.format(epoch + 1,\n"," batch,\n"," batch_loss.numpy()))\n","\n"," loss = total_loss / steps_per_epoch\n"," # save checkpoints with best loss\n"," if loss < best_loss:\n"," best_loss = loss\n"," print('Saving checkpoint for epoch {} Loss {:.4f}'.format(epoch + 1, total_loss / steps_per_epoch))\n"," checkpoint.save(file_prefix = checkpoint_prefix)\n","\n"," print('Epoch {} Loss {:.4f}'.format(epoch + 1,\n"," total_loss / steps_per_epoch))\n"," print('Time taken for 1 epoch {} sec\\n'.format(time.time() - start))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":1000},"id":"_ZheDY-jc7P7","executionInfo":{"status":"error","timestamp":1639601960592,"user_tz":480,"elapsed":8517311,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"8ba96294-0a8d-4c52-ca2f-f5b6054a4287"},"execution_count":25,"outputs":[{"output_type":"stream","name":"stdout","text":["Epoch 1 Batch 0 Loss 0.6585\n","Epoch 1 Batch 100 Loss 0.4614\n","Epoch 1 Batch 200 Loss 0.2636\n","Epoch 1 Batch 300 Loss 0.1927\n","Epoch 1 Batch 400 Loss 0.1635\n","Epoch 1 Batch 500 Loss 0.1268\n","Epoch 1 Batch 600 Loss 0.1506\n","Epoch 1 Batch 700 Loss 0.1183\n","Epoch 1 Batch 800 Loss 0.1279\n","Epoch 1 Batch 900 Loss 0.0877\n","Epoch 1 Batch 1000 Loss 0.1213\n","Epoch 1 Batch 1100 Loss 0.1009\n","Epoch 1 Batch 1200 Loss 0.0971\n","Epoch 1 Batch 1300 Loss 0.1098\n","Epoch 1 Batch 1400 Loss 0.0898\n","Saving checkpoint for epoch 1 Loss 0.1385\n","Epoch 1 Loss 0.1385\n","Time taken for 1 epoch 227.73123383522034 sec\n","\n","Epoch 2 Batch 0 Loss 0.0962\n","Epoch 2 Batch 100 Loss 0.0923\n","Epoch 2 Batch 200 Loss 0.0889\n","Epoch 2 Batch 300 Loss 0.0975\n","Epoch 2 Batch 400 Loss 0.1080\n","Epoch 2 Batch 500 Loss 0.0906\n","Epoch 2 Batch 600 Loss 0.0884\n","Epoch 2 Batch 700 Loss 0.0850\n","Epoch 2 Batch 800 Loss 0.1165\n","Epoch 2 Batch 900 Loss 0.1037\n","Epoch 2 Batch 1000 Loss 0.0831\n","Epoch 2 Batch 1100 Loss 0.0702\n","Epoch 2 Batch 1200 Loss 0.0818\n","Epoch 2 Batch 1300 Loss 0.0765\n","Epoch 2 Batch 1400 Loss 0.1210\n","Saving checkpoint for epoch 2 Loss 0.0768\n","Epoch 2 Loss 0.0768\n","Time taken for 1 epoch 216.80077624320984 sec\n","\n","Epoch 3 Batch 0 Loss 0.0927\n","Epoch 3 Batch 100 Loss 0.0828\n","Epoch 3 Batch 200 Loss 0.0783\n","Epoch 3 Batch 300 Loss 0.1083\n","Epoch 3 Batch 400 Loss 0.0958\n","Epoch 3 Batch 500 Loss 0.0878\n","Epoch 3 Batch 600 Loss 0.1080\n","Epoch 3 Batch 700 Loss 0.1033\n","Epoch 3 Batch 800 Loss 0.0946\n","Epoch 3 Batch 900 Loss 0.0837\n","Epoch 3 Batch 1000 Loss 0.0843\n","Epoch 3 Batch 1100 Loss 0.0875\n","Epoch 3 Batch 1200 Loss 0.0908\n","Epoch 3 Batch 1300 Loss 0.1002\n","Epoch 3 Batch 1400 Loss 0.0792\n","Saving checkpoint for epoch 3 Loss 0.0694\n","Epoch 3 Loss 0.0694\n","Time taken for 1 epoch 216.83542776107788 sec\n","\n","Epoch 4 Batch 0 Loss 0.1024\n","Epoch 4 Batch 100 Loss 0.0861\n","Epoch 4 Batch 200 Loss 0.0865\n","Epoch 4 Batch 300 Loss 0.0876\n","Epoch 4 Batch 400 Loss 0.0810\n","Epoch 4 Batch 500 Loss 0.0975\n","Epoch 4 Batch 600 Loss 0.0662\n","Epoch 4 Batch 700 Loss 0.0791\n","Epoch 4 Batch 800 Loss 0.0781\n","Epoch 4 Batch 900 Loss 0.0977\n","Epoch 4 Batch 1000 Loss 0.0826\n","Epoch 4 Batch 1100 Loss 0.0771\n","Epoch 4 Batch 1200 Loss 0.0843\n","Epoch 4 Batch 1300 Loss 0.0915\n","Epoch 4 Batch 1400 Loss 0.0861\n","Saving checkpoint for epoch 4 Loss 0.0648\n","Epoch 4 Loss 0.0648\n","Time taken for 1 epoch 216.79546356201172 sec\n","\n","Epoch 5 Batch 0 Loss 0.0823\n","Epoch 5 Batch 100 Loss 0.0765\n","Epoch 5 Batch 200 Loss 0.0720\n","Epoch 5 Batch 300 Loss 0.0765\n","Epoch 5 Batch 400 Loss 0.0794\n","Epoch 5 Batch 500 Loss 0.0738\n","Epoch 5 Batch 600 Loss 0.0808\n","Epoch 5 Batch 700 Loss 0.0675\n","Epoch 5 Batch 800 Loss 0.0609\n","Epoch 5 Batch 900 Loss 0.0823\n","Epoch 5 Batch 1000 Loss 0.0677\n","Epoch 5 Batch 1100 Loss 0.0746\n","Epoch 5 Batch 1200 Loss 0.0660\n","Epoch 5 Batch 1300 Loss 0.0628\n","Epoch 5 Batch 1400 Loss 0.0579\n","Saving checkpoint for epoch 5 Loss 0.0617\n","Epoch 5 Loss 0.0617\n","Time taken for 1 epoch 217.07507514953613 sec\n","\n","Epoch 6 Batch 0 Loss 0.0833\n","Epoch 6 Batch 100 Loss 0.0590\n","Epoch 6 Batch 200 Loss 0.0667\n","Epoch 6 Batch 300 Loss 0.0700\n","Epoch 6 Batch 400 Loss 0.0731\n","Epoch 6 Batch 500 Loss 0.0769\n","Epoch 6 Batch 600 Loss 0.0617\n","Epoch 6 Batch 700 Loss 0.0590\n","Epoch 6 Batch 800 Loss 0.0817\n","Epoch 6 Batch 900 Loss 0.0627\n","Epoch 6 Batch 1000 Loss 0.0811\n","Epoch 6 Batch 1100 Loss 0.0730\n","Epoch 6 Batch 1200 Loss 0.1019\n","Epoch 6 Batch 1300 Loss 0.0853\n","Epoch 6 Batch 1400 Loss 0.0747\n","Saving checkpoint for epoch 6 Loss 0.0588\n","Epoch 6 Loss 0.0588\n","Time taken for 1 epoch 216.74033045768738 sec\n","\n","Epoch 7 Batch 0 Loss 0.0666\n","Epoch 7 Batch 100 Loss 0.0690\n","Epoch 7 Batch 200 Loss 0.0733\n","Epoch 7 Batch 300 Loss 0.0878\n","Epoch 7 Batch 400 Loss 0.0679\n","Epoch 7 Batch 500 Loss 0.0801\n","Epoch 7 Batch 600 Loss 0.0674\n","Epoch 7 Batch 700 Loss 0.0740\n","Epoch 7 Batch 800 Loss 0.0597\n","Epoch 7 Batch 900 Loss 0.0651\n","Epoch 7 Batch 1000 Loss 0.0690\n","Epoch 7 Batch 1100 Loss 0.0680\n","Epoch 7 Batch 1200 Loss 0.0604\n","Epoch 7 Batch 1300 Loss 0.0780\n","Epoch 7 Batch 1400 Loss 0.0726\n","Saving checkpoint for epoch 7 Loss 0.0563\n","Epoch 7 Loss 0.0563\n","Time taken for 1 epoch 216.64750814437866 sec\n","\n","Epoch 8 Batch 0 Loss 0.0802\n","Epoch 8 Batch 100 Loss 0.0542\n","Epoch 8 Batch 200 Loss 0.0614\n","Epoch 8 Batch 300 Loss 0.0630\n","Epoch 8 Batch 400 Loss 0.0639\n","Epoch 8 Batch 500 Loss 0.0462\n","Epoch 8 Batch 600 Loss 0.0781\n","Epoch 8 Batch 700 Loss 0.0811\n","Epoch 8 Batch 800 Loss 0.0770\n","Epoch 8 Batch 900 Loss 0.0603\n","Epoch 8 Batch 1000 Loss 0.0748\n","Epoch 8 Batch 1100 Loss 0.0605\n","Epoch 8 Batch 1200 Loss 0.0634\n","Epoch 8 Batch 1300 Loss 0.0541\n","Epoch 8 Batch 1400 Loss 0.0638\n","Saving checkpoint for epoch 8 Loss 0.0541\n","Epoch 8 Loss 0.0541\n","Time taken for 1 epoch 218.04501461982727 sec\n","\n","Epoch 9 Batch 0 Loss 0.0575\n","Epoch 9 Batch 100 Loss 0.0633\n","Epoch 9 Batch 200 Loss 0.0788\n","Epoch 9 Batch 300 Loss 0.0720\n","Epoch 9 Batch 400 Loss 0.0616\n","Epoch 9 Batch 500 Loss 0.0662\n","Epoch 9 Batch 600 Loss 0.0694\n","Epoch 9 Batch 700 Loss 0.0693\n","Epoch 9 Batch 800 Loss 0.0665\n","Epoch 9 Batch 900 Loss 0.0632\n","Epoch 9 Batch 1000 Loss 0.0662\n","Epoch 9 Batch 1100 Loss 0.0625\n","Epoch 9 Batch 1200 Loss 0.0581\n","Epoch 9 Batch 1300 Loss 0.0810\n","Epoch 9 Batch 1400 Loss 0.0747\n","Saving checkpoint for epoch 9 Loss 0.0523\n","Epoch 9 Loss 0.0523\n","Time taken for 1 epoch 216.78281354904175 sec\n","\n","Epoch 10 Batch 0 Loss 0.0683\n","Epoch 10 Batch 100 Loss 0.0601\n","Epoch 10 Batch 200 Loss 0.0519\n","Epoch 10 Batch 300 Loss 0.0665\n","Epoch 10 Batch 400 Loss 0.0619\n","Epoch 10 Batch 500 Loss 0.0617\n","Epoch 10 Batch 600 Loss 0.0694\n","Epoch 10 Batch 700 Loss 0.0573\n","Epoch 10 Batch 800 Loss 0.0771\n","Epoch 10 Batch 900 Loss 0.0571\n","Epoch 10 Batch 1000 Loss 0.0617\n","Epoch 10 Batch 1100 Loss 0.0525\n","Epoch 10 Batch 1200 Loss 0.0695\n","Epoch 10 Batch 1300 Loss 0.0739\n","Epoch 10 Batch 1400 Loss 0.0682\n","Saving checkpoint for epoch 10 Loss 0.0503\n","Epoch 10 Loss 0.0503\n","Time taken for 1 epoch 216.3451669216156 sec\n","\n","Epoch 11 Batch 0 Loss 0.0663\n","Epoch 11 Batch 100 Loss 0.0636\n","Epoch 11 Batch 200 Loss 0.0496\n","Epoch 11 Batch 300 Loss 0.0575\n","Epoch 11 Batch 400 Loss 0.0722\n","Epoch 11 Batch 500 Loss 0.0543\n","Epoch 11 Batch 600 Loss 0.0488\n","Epoch 11 Batch 700 Loss 0.0607\n","Epoch 11 Batch 800 Loss 0.0601\n","Epoch 11 Batch 900 Loss 0.0694\n","Epoch 11 Batch 1000 Loss 0.0587\n","Epoch 11 Batch 1100 Loss 0.0662\n","Epoch 11 Batch 1200 Loss 0.0668\n","Epoch 11 Batch 1300 Loss 0.0500\n","Epoch 11 Batch 1400 Loss 0.0546\n","Saving checkpoint for epoch 11 Loss 0.0487\n","Epoch 11 Loss 0.0487\n","Time taken for 1 epoch 217.07855606079102 sec\n","\n","Epoch 12 Batch 0 Loss 0.0537\n","Epoch 12 Batch 100 Loss 0.0632\n","Epoch 12 Batch 200 Loss 0.0628\n","Epoch 12 Batch 300 Loss 0.0570\n","Epoch 12 Batch 400 Loss 0.0841\n","Epoch 12 Batch 500 Loss 0.0543\n","Epoch 12 Batch 600 Loss 0.0562\n","Epoch 12 Batch 700 Loss 0.0774\n","Epoch 12 Batch 800 Loss 0.0532\n","Epoch 12 Batch 900 Loss 0.0707\n","Epoch 12 Batch 1000 Loss 0.0577\n","Epoch 12 Batch 1100 Loss 0.0536\n","Epoch 12 Batch 1200 Loss 0.0787\n","Epoch 12 Batch 1300 Loss 0.0527\n","Epoch 12 Batch 1400 Loss 0.0579\n","Saving checkpoint for epoch 12 Loss 0.0476\n","Epoch 12 Loss 0.0476\n","Time taken for 1 epoch 217.12636995315552 sec\n","\n","Epoch 13 Batch 0 Loss 0.0493\n","Epoch 13 Batch 100 Loss 0.0514\n","Epoch 13 Batch 200 Loss 0.0502\n","Epoch 13 Batch 300 Loss 0.0595\n","Epoch 13 Batch 400 Loss 0.0425\n","Epoch 13 Batch 500 Loss 0.0526\n","Epoch 13 Batch 600 Loss 0.0570\n","Epoch 13 Batch 700 Loss 0.0632\n","Epoch 13 Batch 800 Loss 0.0570\n","Epoch 13 Batch 900 Loss 0.0651\n","Epoch 13 Batch 1000 Loss 0.0578\n","Epoch 13 Batch 1100 Loss 0.0622\n","Epoch 13 Batch 1200 Loss 0.0602\n","Epoch 13 Batch 1300 Loss 0.0454\n","Epoch 13 Batch 1400 Loss 0.0697\n","Saving checkpoint for epoch 13 Loss 0.0470\n","Epoch 13 Loss 0.0470\n","Time taken for 1 epoch 217.09414339065552 sec\n","\n","Epoch 14 Batch 0 Loss 0.0543\n","Epoch 14 Batch 100 Loss 0.0639\n","Epoch 14 Batch 200 Loss 0.0450\n","Epoch 14 Batch 300 Loss 0.0489\n","Epoch 14 Batch 400 Loss 0.0535\n","Epoch 14 Batch 500 Loss 0.0544\n","Epoch 14 Batch 600 Loss 0.0651\n","Epoch 14 Batch 700 Loss 0.0388\n","Epoch 14 Batch 800 Loss 0.0462\n","Epoch 14 Batch 900 Loss 0.0499\n","Epoch 14 Batch 1000 Loss 0.0808\n","Epoch 14 Batch 1100 Loss 0.0550\n","Epoch 14 Batch 1200 Loss 0.0624\n","Epoch 14 Batch 1300 Loss 0.0546\n","Epoch 14 Batch 1400 Loss 0.0538\n","Saving checkpoint for epoch 14 Loss 0.0458\n","Epoch 14 Loss 0.0458\n","Time taken for 1 epoch 217.36542129516602 sec\n","\n","Epoch 15 Batch 0 Loss 0.0384\n","Epoch 15 Batch 100 Loss 0.0514\n","Epoch 15 Batch 200 Loss 0.0449\n","Epoch 15 Batch 300 Loss 0.0537\n","Epoch 15 Batch 400 Loss 0.0657\n","Epoch 15 Batch 500 Loss 0.0722\n","Epoch 15 Batch 600 Loss 0.0537\n","Epoch 15 Batch 700 Loss 0.0598\n","Epoch 15 Batch 800 Loss 0.0538\n","Epoch 15 Batch 900 Loss 0.0421\n","Epoch 15 Batch 1000 Loss 0.0498\n","Epoch 15 Batch 1100 Loss 0.0572\n","Epoch 15 Batch 1200 Loss 0.0591\n","Epoch 15 Batch 1300 Loss 0.0616\n","Epoch 15 Batch 1400 Loss 0.0596\n","Saving checkpoint for epoch 15 Loss 0.0441\n","Epoch 15 Loss 0.0441\n","Time taken for 1 epoch 217.1265778541565 sec\n","\n","Epoch 16 Batch 0 Loss 0.0526\n","Epoch 16 Batch 100 Loss 0.0616\n","Epoch 16 Batch 200 Loss 0.0544\n","Epoch 16 Batch 300 Loss 0.0437\n","Epoch 16 Batch 400 Loss 0.0656\n","Epoch 16 Batch 500 Loss 0.0777\n","Epoch 16 Batch 600 Loss 0.0665\n","Epoch 16 Batch 700 Loss 0.0735\n","Epoch 16 Batch 800 Loss 0.1104\n","Epoch 16 Batch 900 Loss 0.0748\n","Epoch 16 Batch 1000 Loss 0.0486\n","Epoch 16 Batch 1100 Loss 0.0609\n","Epoch 16 Batch 1200 Loss 0.0671\n","Epoch 16 Batch 1300 Loss 0.0710\n","Epoch 16 Batch 1400 Loss 0.0707\n","Epoch 16 Loss 0.0504\n","Time taken for 1 epoch 216.44691610336304 sec\n","\n","Epoch 17 Batch 0 Loss 0.0528\n","Epoch 17 Batch 100 Loss 0.0580\n","Epoch 17 Batch 200 Loss 0.0646\n","Epoch 17 Batch 300 Loss 0.0742\n","Epoch 17 Batch 400 Loss 0.0417\n","Epoch 17 Batch 500 Loss 0.0483\n","Epoch 17 Batch 600 Loss 0.0465\n","Epoch 17 Batch 700 Loss 0.0576\n","Epoch 17 Batch 800 Loss 0.0570\n","Epoch 17 Batch 900 Loss 0.0446\n","Epoch 17 Batch 1000 Loss 0.0492\n","Epoch 17 Batch 1100 Loss 0.0481\n","Epoch 17 Batch 1200 Loss 0.0570\n","Epoch 17 Batch 1300 Loss 0.0502\n","Epoch 17 Batch 1400 Loss 0.0429\n","Saving checkpoint for epoch 17 Loss 0.0439\n","Epoch 17 Loss 0.0439\n","Time taken for 1 epoch 216.74948000907898 sec\n","\n","Epoch 18 Batch 0 Loss 0.0583\n","Epoch 18 Batch 100 Loss 0.0391\n","Epoch 18 Batch 200 Loss 0.0581\n","Epoch 18 Batch 300 Loss 0.0433\n","Epoch 18 Batch 400 Loss 0.0490\n","Epoch 18 Batch 500 Loss 0.0792\n","Epoch 18 Batch 600 Loss 0.0691\n","Epoch 18 Batch 700 Loss 0.0917\n","Epoch 18 Batch 800 Loss 0.0660\n","Epoch 18 Batch 900 Loss 0.0601\n","Epoch 18 Batch 1000 Loss 0.0536\n","Epoch 18 Batch 1100 Loss 0.0535\n","Epoch 18 Batch 1200 Loss 0.0547\n","Epoch 18 Batch 1300 Loss 0.0610\n","Epoch 18 Batch 1400 Loss 0.0636\n","Epoch 18 Loss 0.0478\n","Time taken for 1 epoch 216.33429789543152 sec\n","\n","Epoch 19 Batch 0 Loss 0.0566\n","Epoch 19 Batch 100 Loss 0.0536\n","Epoch 19 Batch 200 Loss 0.0735\n","Epoch 19 Batch 300 Loss 11.8572\n","Epoch 19 Batch 400 Loss 0.6993\n","Epoch 19 Batch 500 Loss 0.6136\n","Epoch 19 Batch 600 Loss 0.5357\n","Epoch 19 Batch 700 Loss 0.5451\n","Epoch 19 Batch 800 Loss 0.4911\n","Epoch 19 Batch 900 Loss 0.4822\n","Epoch 19 Batch 1000 Loss 0.4862\n","Epoch 19 Batch 1100 Loss 0.5717\n","Epoch 19 Batch 1200 Loss 0.5426\n","Epoch 19 Batch 1300 Loss 0.4616\n","Epoch 19 Batch 1400 Loss 0.4466\n","Epoch 19 Loss 0.7224\n","Time taken for 1 epoch 215.88376593589783 sec\n","\n","Epoch 20 Batch 0 Loss 0.5060\n","Epoch 20 Batch 100 Loss 0.4890\n","Epoch 20 Batch 200 Loss 0.4846\n","Epoch 20 Batch 300 Loss 0.4650\n","Epoch 20 Batch 400 Loss 0.3901\n","Epoch 20 Batch 500 Loss 0.5108\n","Epoch 20 Batch 600 Loss 0.4745\n","Epoch 20 Batch 700 Loss 0.4956\n","Epoch 20 Batch 800 Loss 0.4519\n","Epoch 20 Batch 900 Loss 0.4320\n","Epoch 20 Batch 1000 Loss 0.4283\n","Epoch 20 Batch 1100 Loss 0.4329\n","Epoch 20 Batch 1200 Loss 0.4607\n","Epoch 20 Batch 1300 Loss 0.4068\n","Epoch 20 Batch 1400 Loss 0.4447\n","Epoch 20 Loss 0.3752\n","Time taken for 1 epoch 216.2054944038391 sec\n","\n","Epoch 21 Batch 0 Loss 0.4808\n","Epoch 21 Batch 100 Loss 0.4414\n","Epoch 21 Batch 200 Loss 0.4532\n","Epoch 21 Batch 300 Loss 0.4620\n","Epoch 21 Batch 400 Loss 0.4305\n","Epoch 21 Batch 500 Loss 0.4165\n","Epoch 21 Batch 600 Loss 0.4444\n","Epoch 21 Batch 700 Loss 0.4106\n","Epoch 21 Batch 800 Loss 0.4192\n","Epoch 21 Batch 900 Loss 0.4190\n","Epoch 21 Batch 1000 Loss 0.4793\n","Epoch 21 Batch 1100 Loss 0.4304\n","Epoch 21 Batch 1200 Loss 0.3996\n","Epoch 21 Batch 1300 Loss 0.4035\n","Epoch 21 Batch 1400 Loss 0.3630\n","Epoch 21 Loss 0.3465\n","Time taken for 1 epoch 216.23831582069397 sec\n","\n","Epoch 22 Batch 0 Loss 0.4185\n","Epoch 22 Batch 100 Loss 0.4254\n","Epoch 22 Batch 200 Loss 0.3933\n","Epoch 22 Batch 300 Loss 0.4342\n","Epoch 22 Batch 400 Loss 0.4231\n","Epoch 22 Batch 500 Loss 0.4066\n","Epoch 22 Batch 600 Loss 0.3613\n","Epoch 22 Batch 700 Loss 0.3751\n","Epoch 22 Batch 800 Loss 0.3776\n","Epoch 22 Batch 900 Loss 0.4040\n","Epoch 22 Batch 1000 Loss 0.3930\n","Epoch 22 Batch 1100 Loss 0.3928\n","Epoch 22 Batch 1200 Loss 0.4035\n","Epoch 22 Batch 1300 Loss 0.3902\n","Epoch 22 Batch 1400 Loss 0.3717\n","Epoch 22 Loss 0.3133\n","Time taken for 1 epoch 216.46002674102783 sec\n","\n","Epoch 23 Batch 0 Loss 0.3767\n","Epoch 23 Batch 100 Loss 0.3706\n","Epoch 23 Batch 200 Loss 0.3244\n","Epoch 23 Batch 300 Loss 0.3935\n","Epoch 23 Batch 400 Loss 0.3544\n","Epoch 23 Batch 500 Loss 0.3494\n","Epoch 23 Batch 600 Loss 0.3665\n","Epoch 23 Batch 700 Loss 0.3784\n","Epoch 23 Batch 800 Loss 0.3069\n","Epoch 23 Batch 900 Loss 0.3602\n","Epoch 23 Batch 1000 Loss 0.3564\n","Epoch 23 Batch 1100 Loss 0.3449\n","Epoch 23 Batch 1200 Loss 0.3171\n","Epoch 23 Batch 1300 Loss 0.3045\n","Epoch 23 Batch 1400 Loss 0.3028\n","Epoch 23 Loss 0.2776\n","Time taken for 1 epoch 216.62765049934387 sec\n","\n","Epoch 24 Batch 0 Loss 0.3092\n","Epoch 24 Batch 100 Loss 0.3085\n","Epoch 24 Batch 200 Loss 0.3036\n","Epoch 24 Batch 300 Loss 0.3162\n","Epoch 24 Batch 400 Loss 0.3505\n","Epoch 24 Batch 500 Loss 0.3449\n","Epoch 24 Batch 600 Loss 0.2938\n","Epoch 24 Batch 700 Loss 0.2867\n","Epoch 24 Batch 800 Loss 0.2960\n","Epoch 24 Batch 900 Loss 0.3104\n","Epoch 24 Batch 1000 Loss 0.2761\n","Epoch 24 Batch 1100 Loss 0.3364\n","Epoch 24 Batch 1200 Loss 0.3030\n","Epoch 24 Batch 1300 Loss 0.3251\n","Epoch 24 Batch 1400 Loss 0.2712\n","Epoch 24 Loss 0.2398\n","Time taken for 1 epoch 216.3007092475891 sec\n","\n","Epoch 25 Batch 0 Loss 0.2838\n","Epoch 25 Batch 100 Loss 0.2892\n","Epoch 25 Batch 200 Loss 0.2655\n","Epoch 25 Batch 300 Loss 0.2574\n","Epoch 25 Batch 400 Loss 0.3017\n","Epoch 25 Batch 500 Loss 0.2642\n","Epoch 25 Batch 600 Loss 0.2894\n","Epoch 25 Batch 700 Loss 0.2473\n","Epoch 25 Batch 800 Loss 0.2753\n","Epoch 25 Batch 900 Loss 0.2685\n","Epoch 25 Batch 1000 Loss 0.2482\n","Epoch 25 Batch 1100 Loss 0.2630\n","Epoch 25 Batch 1200 Loss 0.2742\n","Epoch 25 Batch 1300 Loss 0.2233\n","Epoch 25 Batch 1400 Loss 0.2545\n","Epoch 25 Loss 0.2102\n","Time taken for 1 epoch 216.30212783813477 sec\n","\n","Epoch 26 Batch 0 Loss 0.2228\n","Epoch 26 Batch 100 Loss 0.2102\n","Epoch 26 Batch 200 Loss 0.2431\n","Epoch 26 Batch 300 Loss 0.2197\n","Epoch 26 Batch 400 Loss 0.2672\n","Epoch 26 Batch 500 Loss 0.2002\n","Epoch 26 Batch 600 Loss 0.2294\n","Epoch 26 Batch 700 Loss 0.2751\n","Epoch 26 Batch 800 Loss 0.2022\n","Epoch 26 Batch 900 Loss 0.2441\n","Epoch 26 Batch 1000 Loss 0.1885\n","Epoch 26 Batch 1100 Loss 0.2022\n","Epoch 26 Batch 1200 Loss 0.2192\n","Epoch 26 Batch 1300 Loss 0.2143\n","Epoch 26 Batch 1400 Loss 0.2423\n","Epoch 26 Loss 0.1893\n","Time taken for 1 epoch 216.07285499572754 sec\n","\n","Epoch 27 Batch 0 Loss 0.2653\n","Epoch 27 Batch 100 Loss 0.2166\n","Epoch 27 Batch 200 Loss 0.1851\n","Epoch 27 Batch 300 Loss 0.2496\n","Epoch 27 Batch 400 Loss 0.2235\n","Epoch 27 Batch 500 Loss 0.1978\n","Epoch 27 Batch 600 Loss 0.2155\n","Epoch 27 Batch 700 Loss 0.2084\n","Epoch 27 Batch 800 Loss 0.2083\n","Epoch 27 Batch 900 Loss 0.2206\n","Epoch 27 Batch 1000 Loss 0.2307\n","Epoch 27 Batch 1100 Loss 0.2379\n","Epoch 27 Batch 1200 Loss 0.2038\n","Epoch 27 Batch 1300 Loss 0.2184\n","Epoch 27 Batch 1400 Loss 0.1826\n","Epoch 27 Loss 0.1743\n","Time taken for 1 epoch 216.1950900554657 sec\n","\n","Epoch 28 Batch 0 Loss 0.1803\n","Epoch 28 Batch 100 Loss 0.2537\n","Epoch 28 Batch 200 Loss 0.1809\n","Epoch 28 Batch 300 Loss 0.2095\n","Epoch 28 Batch 400 Loss 0.1946\n","Epoch 28 Batch 500 Loss 0.2316\n","Epoch 28 Batch 600 Loss 1.4413\n","Epoch 28 Batch 700 Loss 0.7572\n","Epoch 28 Batch 800 Loss 0.6344\n","Epoch 28 Batch 900 Loss 0.4926\n","Epoch 28 Batch 1000 Loss 0.4719\n","Epoch 28 Batch 1100 Loss 0.4787\n","Epoch 28 Batch 1200 Loss 0.4777\n","Epoch 28 Batch 1300 Loss 0.4844\n","Epoch 28 Batch 1400 Loss 0.4022\n","Epoch 28 Loss 0.5692\n","Time taken for 1 epoch 215.6400966644287 sec\n","\n","Epoch 29 Batch 0 Loss 0.4469\n","Epoch 29 Batch 100 Loss 0.4507\n","Epoch 29 Batch 200 Loss 0.4484\n","Epoch 29 Batch 300 Loss 0.5026\n","Epoch 29 Batch 400 Loss 0.4396\n","Epoch 29 Batch 500 Loss 0.4346\n","Epoch 29 Batch 600 Loss 0.4787\n","Epoch 29 Batch 700 Loss 0.4405\n","Epoch 29 Batch 800 Loss 0.4562\n","Epoch 29 Batch 900 Loss 0.4348\n","Epoch 29 Batch 1000 Loss 0.4896\n","Epoch 29 Batch 1100 Loss 0.4202\n","Epoch 29 Batch 1200 Loss 0.3888\n","Epoch 29 Batch 1300 Loss 0.4199\n","Epoch 29 Batch 1400 Loss 0.3979\n","Epoch 29 Loss 0.3485\n","Time taken for 1 epoch 216.3094882965088 sec\n","\n","Epoch 30 Batch 0 Loss 0.4131\n","Epoch 30 Batch 100 Loss 0.4732\n","Epoch 30 Batch 200 Loss 0.4033\n","Epoch 30 Batch 300 Loss 0.4151\n","Epoch 30 Batch 400 Loss 0.4154\n","Epoch 30 Batch 500 Loss 0.3961\n","Epoch 30 Batch 600 Loss 0.3999\n","Epoch 30 Batch 700 Loss 0.3937\n","Epoch 30 Batch 800 Loss 0.3324\n","Epoch 30 Batch 900 Loss 0.4075\n","Epoch 30 Batch 1000 Loss 0.4259\n","Epoch 30 Batch 1100 Loss 0.3506\n","Epoch 30 Batch 1200 Loss 0.3829\n","Epoch 30 Batch 1300 Loss 0.3448\n","Epoch 30 Batch 1400 Loss 0.4259\n","Epoch 30 Loss 0.3153\n","Time taken for 1 epoch 215.9945285320282 sec\n","\n","Epoch 31 Batch 0 Loss 0.3476\n","Epoch 31 Batch 100 Loss 0.3562\n","Epoch 31 Batch 200 Loss 0.3866\n","Epoch 31 Batch 300 Loss 0.3585\n","Epoch 31 Batch 400 Loss 0.3627\n","Epoch 31 Batch 500 Loss 0.3438\n","Epoch 31 Batch 600 Loss 0.3527\n","Epoch 31 Batch 700 Loss 0.3449\n","Epoch 31 Batch 800 Loss 0.3534\n","Epoch 31 Batch 900 Loss 0.4610\n","Epoch 31 Batch 1000 Loss 0.3393\n","Epoch 31 Batch 1100 Loss 0.2859\n","Epoch 31 Batch 1200 Loss 0.3857\n","Epoch 31 Batch 1300 Loss 0.3691\n","Epoch 31 Batch 1400 Loss 0.3771\n","Epoch 31 Loss 0.2828\n","Time taken for 1 epoch 215.6908769607544 sec\n","\n","Epoch 32 Batch 0 Loss 0.3332\n","Epoch 32 Batch 100 Loss 0.3151\n","Epoch 32 Batch 200 Loss 0.2643\n","Epoch 32 Batch 300 Loss 0.2924\n","Epoch 32 Batch 400 Loss 0.3179\n","Epoch 32 Batch 500 Loss 0.2769\n","Epoch 32 Batch 600 Loss 0.3132\n","Epoch 32 Batch 700 Loss 0.3929\n","Epoch 32 Batch 800 Loss 0.2747\n","Epoch 32 Batch 900 Loss 0.3141\n","Epoch 32 Batch 1000 Loss 0.2998\n","Epoch 32 Batch 1100 Loss 0.3390\n","Epoch 32 Batch 1200 Loss 0.2763\n","Epoch 32 Batch 1300 Loss 0.2712\n","Epoch 32 Batch 1400 Loss 0.2177\n","Epoch 32 Loss 0.2355\n","Time taken for 1 epoch 215.89790678024292 sec\n","\n","Epoch 33 Batch 0 Loss 0.2708\n","Epoch 33 Batch 100 Loss 0.2507\n","Epoch 33 Batch 200 Loss 0.3246\n","Epoch 33 Batch 300 Loss 0.2381\n","Epoch 33 Batch 400 Loss 0.2005\n","Epoch 33 Batch 500 Loss 0.1731\n","Epoch 33 Batch 600 Loss 0.2504\n","Epoch 33 Batch 700 Loss 0.2040\n","Epoch 33 Batch 800 Loss 0.2481\n","Epoch 33 Batch 900 Loss 0.2100\n","Epoch 33 Batch 1000 Loss 0.2158\n","Epoch 33 Batch 1100 Loss 0.2153\n","Epoch 33 Batch 1200 Loss 0.1827\n","Epoch 33 Batch 1300 Loss 0.2117\n","Epoch 33 Batch 1400 Loss 0.2167\n","Epoch 33 Loss 0.1814\n","Time taken for 1 epoch 216.00964379310608 sec\n","\n","Epoch 34 Batch 0 Loss 0.2085\n","Epoch 34 Batch 100 Loss 0.2462\n","Epoch 34 Batch 200 Loss 0.1985\n","Epoch 34 Batch 300 Loss 0.1953\n","Epoch 34 Batch 400 Loss 0.1721\n","Epoch 34 Batch 500 Loss 0.1682\n","Epoch 34 Batch 600 Loss 0.2310\n","Epoch 34 Batch 700 Loss 0.1411\n","Epoch 34 Batch 800 Loss 0.1809\n","Epoch 34 Batch 900 Loss 0.1937\n","Epoch 34 Batch 1000 Loss 0.1523\n","Epoch 34 Batch 1100 Loss 0.1518\n","Epoch 34 Batch 1200 Loss 0.2194\n","Epoch 34 Batch 1300 Loss 0.2112\n","Epoch 34 Batch 1400 Loss 0.1760\n","Epoch 34 Loss 0.1476\n","Time taken for 1 epoch 215.72388172149658 sec\n","\n","Epoch 35 Batch 0 Loss 0.1753\n","Epoch 35 Batch 100 Loss 0.2140\n","Epoch 35 Batch 200 Loss 0.1580\n","Epoch 35 Batch 300 Loss 0.1549\n","Epoch 35 Batch 400 Loss 0.1323\n","Epoch 35 Batch 500 Loss 0.2085\n","Epoch 35 Batch 600 Loss 0.1392\n","Epoch 35 Batch 700 Loss 0.1467\n","Epoch 35 Batch 800 Loss 0.1595\n","Epoch 35 Batch 900 Loss 0.1778\n","Epoch 35 Batch 1000 Loss 0.1425\n","Epoch 35 Batch 1100 Loss 0.1537\n","Epoch 35 Batch 1200 Loss 0.1585\n","Epoch 35 Batch 1300 Loss 0.1308\n","Epoch 35 Batch 1400 Loss 0.1334\n","Epoch 35 Loss 0.1294\n","Time taken for 1 epoch 216.04845690727234 sec\n","\n","Epoch 36 Batch 0 Loss 0.1561\n","Epoch 36 Batch 100 Loss 0.1444\n","Epoch 36 Batch 200 Loss 0.1757\n","Epoch 36 Batch 300 Loss 0.1500\n","Epoch 36 Batch 400 Loss 0.1194\n","Epoch 36 Batch 500 Loss 0.1568\n","Epoch 36 Batch 600 Loss 0.1523\n","Epoch 36 Batch 700 Loss 0.1396\n","Epoch 36 Batch 800 Loss 0.1459\n","Epoch 36 Batch 900 Loss 0.1442\n","Epoch 36 Batch 1000 Loss 0.1270\n","Epoch 36 Batch 1100 Loss 0.1508\n","Epoch 36 Batch 1200 Loss 0.1186\n","Epoch 36 Batch 1300 Loss 0.1338\n","Epoch 36 Batch 1400 Loss 0.1452\n","Epoch 36 Loss 0.1219\n","Time taken for 1 epoch 216.12925267219543 sec\n","\n","Epoch 37 Batch 0 Loss 0.1259\n","Epoch 37 Batch 100 Loss 0.2299\n","Epoch 37 Batch 200 Loss 0.1511\n","Epoch 37 Batch 300 Loss 0.1224\n","Epoch 37 Batch 400 Loss 0.1803\n","Epoch 37 Batch 500 Loss 0.1717\n","Epoch 37 Batch 600 Loss 0.1432\n","Epoch 37 Batch 700 Loss 0.1566\n","Epoch 37 Batch 800 Loss 0.1403\n","Epoch 37 Batch 900 Loss 0.1434\n","Epoch 37 Batch 1000 Loss 0.1901\n","Epoch 37 Batch 1100 Loss 0.1919\n","Epoch 37 Batch 1200 Loss 0.1521\n","Epoch 37 Batch 1300 Loss 0.1571\n","Epoch 37 Batch 1400 Loss 0.1507\n","Epoch 37 Loss 0.1267\n","Time taken for 1 epoch 216.19201564788818 sec\n","\n","Epoch 38 Batch 0 Loss 0.1392\n","Epoch 38 Batch 100 Loss 0.1169\n","Epoch 38 Batch 200 Loss 0.1008\n","Epoch 38 Batch 300 Loss 0.1345\n","Epoch 38 Batch 400 Loss 0.1440\n","Epoch 38 Batch 500 Loss 0.1479\n","Epoch 38 Batch 600 Loss 0.1517\n","Epoch 38 Batch 700 Loss 0.1463\n","Epoch 38 Batch 800 Loss 0.1414\n","Epoch 38 Batch 900 Loss 0.1952\n","Epoch 38 Batch 1000 Loss 0.1482\n","Epoch 38 Batch 1100 Loss 0.1233\n","Epoch 38 Batch 1200 Loss 0.1409\n","Epoch 38 Batch 1300 Loss 0.1630\n","Epoch 38 Batch 1400 Loss 0.1235\n","Epoch 38 Loss 0.1198\n","Time taken for 1 epoch 216.24167585372925 sec\n","\n","Epoch 39 Batch 0 Loss 0.1349\n","Epoch 39 Batch 100 Loss 0.1506\n","Epoch 39 Batch 200 Loss 0.1386\n","Epoch 39 Batch 300 Loss 0.1603\n","Epoch 39 Batch 400 Loss 0.1628\n","Epoch 39 Batch 500 Loss 0.2064\n","Epoch 39 Batch 600 Loss 0.1422\n","Epoch 39 Batch 700 Loss 0.1225\n","Epoch 39 Batch 800 Loss 0.1427\n","Epoch 39 Batch 900 Loss 0.1642\n","Epoch 39 Batch 1000 Loss 0.1164\n","Epoch 39 Batch 1100 Loss 0.1684\n","Epoch 39 Batch 1200 Loss 0.1338\n","Epoch 39 Batch 1300 Loss 0.1458\n","Epoch 39 Batch 1400 Loss 0.1073\n","Epoch 39 Loss 0.1196\n","Time taken for 1 epoch 215.96283411979675 sec\n","\n","Epoch 40 Batch 0 Loss 0.1166\n","Epoch 40 Batch 100 Loss 0.1482\n","Epoch 40 Batch 200 Loss 0.1359\n","Epoch 40 Batch 300 Loss 2.2848\n","Epoch 40 Batch 400 Loss 0.7020\n"]},{"output_type":"error","ename":"KeyboardInterrupt","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-25-8c01f4b222cb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;31m# print(enc_hidden[0].shape, enc_hidden[1].shape)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mbatch\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0minp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtarg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_dataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtake\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msteps_per_epoch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mbatch_loss\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrain_step\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtarg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0menc_hidden\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 12\u001b[0m \u001b[0mtotal_loss\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0mbatch_loss\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/traceback_utils.py\u001b[0m in \u001b[0;36merror_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 148\u001b[0m \u001b[0mfiltered_tb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 149\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 150\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 151\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 152\u001b[0m \u001b[0mfiltered_tb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_process_traceback_frames\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__traceback__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 908\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 909\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mOptionalXlaContext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_jit_compile\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 910\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 911\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 912\u001b[0m \u001b[0mnew_tracing_count\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental_get_tracing_count\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m_call\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 940\u001b[0m \u001b[0;31m# In this case we have created variables on the first call, so we run the\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 941\u001b[0m \u001b[0;31m# defunned version which is guaranteed to never create variables.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 942\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stateless_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# pylint: disable=not-callable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 943\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stateful_fn\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 944\u001b[0m \u001b[0;31m# Release the lock early so that multiple threads can perform the call\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 3129\u001b[0m filtered_flat_args) = self._maybe_define_function(args, kwargs)\n\u001b[1;32m 3130\u001b[0m return graph_function._call_flat(\n\u001b[0;32m-> 3131\u001b[0;31m filtered_flat_args, captured_inputs=graph_function.captured_inputs) # pylint: disable=protected-access\n\u001b[0m\u001b[1;32m 3132\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3133\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_flat\u001b[0;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1958\u001b[0m \u001b[0;31m# No tape is watching; skip to running the function.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1959\u001b[0m return self._build_call_outputs(self._inference_function.call(\n\u001b[0;32m-> 1960\u001b[0;31m ctx, args, cancellation_manager=cancellation_manager))\n\u001b[0m\u001b[1;32m 1961\u001b[0m forward_backward = self._select_forward_and_backward_functions(\n\u001b[1;32m 1962\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[1;32m 601\u001b[0m \u001b[0minputs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 602\u001b[0m \u001b[0mattrs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mattrs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 603\u001b[0;31m ctx=ctx)\n\u001b[0m\u001b[1;32m 604\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 605\u001b[0m outputs = execute.execute_with_cancellation(\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py\u001b[0m in \u001b[0;36mquick_execute\u001b[0;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[0mctx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mensure_initialized\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 58\u001b[0m tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,\n\u001b[0;32m---> 59\u001b[0;31m inputs, attrs, num_outputs)\n\u001b[0m\u001b[1;32m 60\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_NotOkStatusException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 61\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "]}]},{"cell_type":"code","source":["encoder.embedding.variables"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Ron5dNu1nG7a","executionInfo":{"status":"ok","timestamp":1639601964577,"user_tz":480,"elapsed":177,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"5a19e21e-f9f5-4767-fca6-11c75494f37a"},"execution_count":26,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[<tf.Variable 'encoder/embedding/embeddings:0' shape=(166, 256) dtype=float32, numpy=\n"," array([[-0.07065372, -0.04891422, 0.01282918, ..., 0.04568648,\n"," -0.07823983, -0.07764788],\n"," [-0.09147184, 0.19109847, 0.12537214, ..., -0.01790996,\n"," 0.00141883, -0.18570372],\n"," [ 0.03353083, 0.1054965 , -0.06611574, ..., 0.01166355,\n"," -0.11960571, -0.16839524],\n"," ...,\n"," [-0.19065775, 0.28302342, 0.07893948, ..., -0.1513373 ,\n"," 0.04492971, 0.12638961],\n"," [ 0.09505298, -0.44047958, 0.02591725, ..., -0.02426921,\n"," -0.421986 , 0.23949109],\n"," [-0.01180682, 0.13395208, 0.03590768, ..., 0.10349247,\n"," -0.02466262, 0.2182667 ]], dtype=float32)>]"]},"metadata":{},"execution_count":26}]},{"cell_type":"code","source":["decoder.embedding.variables"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"lv3y11v-nLK0","executionInfo":{"status":"ok","timestamp":1639601967358,"user_tz":480,"elapsed":193,"user":{"displayName":"Rajashekar Chintalapati","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhvaKS4oQw2sBCyEe0cxq9rGBNCg4w2UoWOgVaD660=s64","userId":"03596288833202137831"}},"outputId":"67c67bbf-a865-4521-b6bc-cd13ed393198"},"execution_count":27,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[<tf.Variable 'decoder/embedding_1/embeddings:0' shape=(36, 256) dtype=float32, numpy=\n"," array([[ 0.03724634, -0.02989709, -0.04813312, ..., -0.00780924,\n"," 0.00926129, 0.04338977],\n"," [ 0.46307915, -0.22748752, -0.31411505, ..., 0.7708867 ,\n"," -0.1213175 , -0.47693196],\n"," [ 0.05063611, 0.08911494, -0.11557912, ..., 0.0591362 ,\n"," -0.04259794, -0.08504502],\n"," ...,\n"," [-0.557036 , -0.32107395, 0.31832972, ..., 0.02268083,\n"," -0.10818028, -0.12645367],\n"," [ 0.45082635, 0.03947921, -0.22183114, ..., -0.04993758,\n"," 0.01296891, -0.06116186],\n"," [-0.00486869, -0.15992434, 0.17243467, ..., 0.11373673,\n"," 0.10106619, 0.16622567]], dtype=float32)>]"]},"metadata":{},"execution_count":27}]},{"cell_type":"code","source":[""],"metadata":{"id":"bL2ukuAgrCrN"},"execution_count":null,"outputs":[]}]}