DL_SEQ2SEQ/seq2seq-keras-falied-attempt.ipynb
2024-06-03 06:53:52 +02:00

913 lines
73 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"source": [
"### Imports"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-30T20:13:48.001757Z",
"end_time": "2024-05-30T20:13:52.521965Z"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import keras\n",
"import os\n",
"import tensorflow as tf\n",
"from keras.layers import LSTM, Dense, Input\n",
"from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction\n",
"from tqdm import tqdm\n",
"\n",
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n",
"os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'"
]
},
{
"cell_type": "markdown",
"source": [
"### Check GPU"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 2,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Num GPUs Available: 1\n"
]
}
],
"source": [
"physical_devices = tf.config.experimental.list_physical_devices('GPU')\n",
"print(\"Num GPUs Available: \", len(physical_devices))"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:13:53.186308Z",
"end_time": "2024-05-30T20:13:53.213307Z"
}
}
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-30T20:13:53.201315Z",
"end_time": "2024-05-30T20:13:53.218308Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]\n"
]
}
],
"source": [
"print(tf.config.list_physical_devices('GPU'))"
]
},
{
"cell_type": "markdown",
"source": [
"### Define the model parameters"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-30T20:13:53.217308Z",
"end_time": "2024-05-30T20:13:53.230310Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"batch_size = 16\n",
"epochs = 50\n",
"latent_dim = 256\n",
"num_samples = 40000\n",
"data_path = \"pol-eng/pol.txt\""
]
},
{
"cell_type": "markdown",
"source": [
"### Read the data"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-30T20:13:53.235337Z",
"end_time": "2024-05-30T20:13:53.453309Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of samples: 40000\n",
"Number of unique input tokens: 76\n",
"Number of unique output tokens: 99\n",
"Max sequence length for inputs: 39\n",
"Max sequence length for outputs: 68\n"
]
}
],
"source": [
"input_texts = []\n",
"target_texts = []\n",
"input_characters = set()\n",
"target_characters = set()\n",
"with open(data_path, \"r\", encoding=\"utf-8\") as f:\n",
" lines = f.read().split(\"\\n\")\n",
"for line in lines[: min(num_samples, len(lines) - 1)]:\n",
" input_text, target_text, _ = line.split(\"\\t\")\n",
"\n",
" target_text = \"\\t\" + target_text + \"\\n\"\n",
" input_texts.append(input_text)\n",
" target_texts.append(target_text)\n",
" for char in input_text:\n",
" if char not in input_characters:\n",
" input_characters.add(char)\n",
" for char in target_text:\n",
" if char not in target_characters:\n",
" target_characters.add(char)\n",
"\n",
"input_characters = sorted(list(input_characters))\n",
"target_characters = sorted(list(target_characters))\n",
"num_encoder_tokens = len(input_characters)\n",
"num_decoder_tokens = len(target_characters)\n",
"max_encoder_seq_length = max([len(txt) for txt in input_texts])\n",
"max_decoder_seq_length = max([len(txt) for txt in target_texts])\n",
"\n",
"print(\"Number of samples:\", len(input_texts))\n",
"print(\"Number of unique input tokens:\", num_encoder_tokens)\n",
"print(\"Number of unique output tokens:\", num_decoder_tokens)\n",
"print(\"Max sequence length for inputs:\", max_encoder_seq_length)\n",
"print(\"Max sequence length for outputs:\", max_decoder_seq_length)"
]
},
{
"cell_type": "markdown",
"source": [
"### Define the input and target data"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [],
"source": [
"input_token_index = dict([(char, i) for i, char in enumerate(input_characters)])\n",
"target_token_index = dict([(char, i) for i, char in enumerate(target_characters)])\n",
"\n",
"encoder_input_data = np.zeros(\n",
" (len(input_texts), max_encoder_seq_length, num_encoder_tokens),\n",
" dtype=\"float32\",\n",
")\n",
"decoder_input_data = np.zeros(\n",
" (len(input_texts), max_decoder_seq_length, num_decoder_tokens),\n",
" dtype=\"float32\",\n",
")\n",
"decoder_target_data = np.zeros(\n",
" (len(input_texts), max_decoder_seq_length, num_decoder_tokens),\n",
" dtype=\"float32\",\n",
")\n",
"\n",
"for i, (input_text, target_text) in enumerate(zip(input_texts, target_texts)):\n",
" for t, char in enumerate(input_text):\n",
" encoder_input_data[i, t, input_token_index[char]] = 1.0\n",
" encoder_input_data[i, t + 1 :, input_token_index[\" \"]] = 1.0\n",
" for t, char in enumerate(target_text):\n",
" decoder_input_data[i, t, target_token_index[char]] = 1.0\n",
" if t > 0:\n",
" decoder_target_data[i, t - 1, target_token_index[char]] = 1.0\n",
" decoder_input_data[i, t + 1 :, target_token_index[\" \"]] = 1.0\n",
" decoder_target_data[i, t:, target_token_index[\" \"]] = 1.0"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:13:53.484306Z",
"end_time": "2024-05-30T20:13:54.609402Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Define the model"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-30T20:13:54.613389Z",
"end_time": "2024-05-30T20:13:56.196206Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"encoder_inputs = Input(shape=(None, num_encoder_tokens))\n",
"encoder = LSTM(latent_dim, return_state=True)\n",
"encoder_outputs, state_h, state_c = encoder(encoder_inputs)\n",
"\n",
"encoder_states = [state_h, state_c]\n",
"\n",
"decoder_inputs = Input(shape=(None, num_decoder_tokens))\n",
"decoder_lstm = LSTM(latent_dim, return_sequences=True, return_state=True)\n",
"decoder_outputs, _, _ = decoder_lstm(decoder_inputs, initial_state=encoder_states)\n",
"decoder_dense = Dense(num_decoder_tokens, activation=\"softmax\")\n",
"decoder_outputs = decoder_dense(decoder_outputs)"
]
},
{
"cell_type": "markdown",
"source": [
"### Train the model"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-29T21:53:07.821344Z",
"end_time": "2024-05-29T22:23:40.488463Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"model = keras.Model([encoder_inputs, decoder_inputs], decoder_outputs)\n",
"model.compile(optimizer=\"rmsprop\", loss=\"categorical_crossentropy\", metrics=[\"accuracy\"])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/50\n",
"2000/2000 [==============================] - 46s 19ms/step - loss: 0.7914 - accuracy: 0.7804 - val_loss: 0.9906 - val_accuracy: 0.7111\n",
"Epoch 2/50\n",
"2000/2000 [==============================] - 34s 17ms/step - loss: 0.5680 - accuracy: 0.8332 - val_loss: 0.8399 - val_accuracy: 0.7529\n",
"Epoch 3/50\n",
"2000/2000 [==============================] - 35s 17ms/step - loss: 0.4870 - accuracy: 0.8568 - val_loss: 0.7561 - val_accuracy: 0.7769\n",
"Epoch 4/50\n",
"2000/2000 [==============================] - 35s 17ms/step - loss: 0.4405 - accuracy: 0.8702 - val_loss: 0.7148 - val_accuracy: 0.7894\n",
"Epoch 5/50\n",
"2000/2000 [==============================] - 37s 18ms/step - loss: 0.4091 - accuracy: 0.8794 - val_loss: 0.6904 - val_accuracy: 0.7963\n",
"Epoch 6/50\n",
"2000/2000 [==============================] - 35s 18ms/step - loss: 0.3858 - accuracy: 0.8860 - val_loss: 0.6719 - val_accuracy: 0.8025\n",
"Epoch 7/50\n",
"2000/2000 [==============================] - 35s 18ms/step - loss: 0.3671 - accuracy: 0.8912 - val_loss: 0.6604 - val_accuracy: 0.8064\n",
"Epoch 8/50\n",
"2000/2000 [==============================] - 37s 18ms/step - loss: 0.3519 - accuracy: 0.8957 - val_loss: 0.6514 - val_accuracy: 0.8100\n",
"Epoch 9/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.3390 - accuracy: 0.8994 - val_loss: 0.6477 - val_accuracy: 0.8112\n",
"Epoch 10/50\n",
"2000/2000 [==============================] - 35s 17ms/step - loss: 0.3282 - accuracy: 0.9025 - val_loss: 0.6460 - val_accuracy: 0.8125\n",
"Epoch 11/50\n",
"2000/2000 [==============================] - 35s 17ms/step - loss: 0.3180 - accuracy: 0.9052 - val_loss: 0.6436 - val_accuracy: 0.8137\n",
"Epoch 12/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.3092 - accuracy: 0.9079 - val_loss: 0.6467 - val_accuracy: 0.8140\n",
"Epoch 13/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.3013 - accuracy: 0.9100 - val_loss: 0.6468 - val_accuracy: 0.8143\n",
"Epoch 14/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2941 - accuracy: 0.9124 - val_loss: 0.6478 - val_accuracy: 0.8149\n",
"Epoch 15/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2876 - accuracy: 0.9140 - val_loss: 0.6510 - val_accuracy: 0.8154\n",
"Epoch 16/50\n",
"2000/2000 [==============================] - 38s 19ms/step - loss: 0.2814 - accuracy: 0.9159 - val_loss: 0.6575 - val_accuracy: 0.8156\n",
"Epoch 17/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2759 - accuracy: 0.9175 - val_loss: 0.6627 - val_accuracy: 0.8146\n",
"Epoch 18/50\n",
"2000/2000 [==============================] - 37s 18ms/step - loss: 0.2702 - accuracy: 0.9190 - val_loss: 0.6649 - val_accuracy: 0.8149\n",
"Epoch 19/50\n",
"2000/2000 [==============================] - 39s 19ms/step - loss: 0.2653 - accuracy: 0.9204 - val_loss: 0.6731 - val_accuracy: 0.8143\n",
"Epoch 20/50\n",
"2000/2000 [==============================] - 37s 19ms/step - loss: 0.2608 - accuracy: 0.9217 - val_loss: 0.6772 - val_accuracy: 0.8135\n",
"Epoch 21/50\n",
"2000/2000 [==============================] - 38s 19ms/step - loss: 0.2562 - accuracy: 0.9230 - val_loss: 0.6812 - val_accuracy: 0.8139\n",
"Epoch 22/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2524 - accuracy: 0.9242 - val_loss: 0.6815 - val_accuracy: 0.8143\n",
"Epoch 23/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2481 - accuracy: 0.9253 - val_loss: 0.6875 - val_accuracy: 0.8135\n",
"Epoch 24/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2448 - accuracy: 0.9264 - val_loss: 0.6945 - val_accuracy: 0.8142\n",
"Epoch 25/50\n",
"2000/2000 [==============================] - 38s 19ms/step - loss: 0.2413 - accuracy: 0.9273 - val_loss: 0.6989 - val_accuracy: 0.8127\n",
"Epoch 26/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2379 - accuracy: 0.9282 - val_loss: 0.7044 - val_accuracy: 0.8129\n",
"Epoch 27/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2349 - accuracy: 0.9291 - val_loss: 0.7080 - val_accuracy: 0.8122\n",
"Epoch 28/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2319 - accuracy: 0.9298 - val_loss: 0.7118 - val_accuracy: 0.8127\n",
"Epoch 29/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2289 - accuracy: 0.9309 - val_loss: 0.7144 - val_accuracy: 0.8124\n",
"Epoch 30/50\n",
"2000/2000 [==============================] - 37s 18ms/step - loss: 0.2263 - accuracy: 0.9315 - val_loss: 0.7215 - val_accuracy: 0.8119\n",
"Epoch 31/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2236 - accuracy: 0.9322 - val_loss: 0.7254 - val_accuracy: 0.8123\n",
"Epoch 32/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2208 - accuracy: 0.9331 - val_loss: 0.7319 - val_accuracy: 0.8111\n",
"Epoch 33/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2188 - accuracy: 0.9334 - val_loss: 0.7390 - val_accuracy: 0.8099\n",
"Epoch 34/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2162 - accuracy: 0.9341 - val_loss: 0.7406 - val_accuracy: 0.8107\n",
"Epoch 35/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2142 - accuracy: 0.9348 - val_loss: 0.7477 - val_accuracy: 0.8101\n",
"Epoch 36/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2122 - accuracy: 0.9356 - val_loss: 0.7504 - val_accuracy: 0.8099\n",
"Epoch 37/50\n",
"2000/2000 [==============================] - 37s 18ms/step - loss: 0.2101 - accuracy: 0.9360 - val_loss: 0.7528 - val_accuracy: 0.8098\n",
"Epoch 38/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2079 - accuracy: 0.9366 - val_loss: 0.7568 - val_accuracy: 0.8103\n",
"Epoch 39/50\n",
"2000/2000 [==============================] - 37s 19ms/step - loss: 0.2063 - accuracy: 0.9369 - val_loss: 0.7615 - val_accuracy: 0.8090\n",
"Epoch 40/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2045 - accuracy: 0.9376 - val_loss: 0.7615 - val_accuracy: 0.8101\n",
"Epoch 41/50\n",
"2000/2000 [==============================] - 37s 19ms/step - loss: 0.2027 - accuracy: 0.9379 - val_loss: 0.7684 - val_accuracy: 0.8089\n",
"Epoch 42/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.2010 - accuracy: 0.9385 - val_loss: 0.7784 - val_accuracy: 0.8080\n",
"Epoch 43/50\n",
"2000/2000 [==============================] - 39s 20ms/step - loss: 0.1993 - accuracy: 0.9389 - val_loss: 0.7801 - val_accuracy: 0.8083\n",
"Epoch 44/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.1978 - accuracy: 0.9393 - val_loss: 0.7780 - val_accuracy: 0.8084\n",
"Epoch 45/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.1961 - accuracy: 0.9397 - val_loss: 0.7928 - val_accuracy: 0.8078\n",
"Epoch 46/50\n",
"2000/2000 [==============================] - 42s 21ms/step - loss: 0.1944 - accuracy: 0.9404 - val_loss: 0.7901 - val_accuracy: 0.8083\n",
"Epoch 47/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.1930 - accuracy: 0.9408 - val_loss: 0.7916 - val_accuracy: 0.8080\n",
"Epoch 48/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.1918 - accuracy: 0.9410 - val_loss: 0.7999 - val_accuracy: 0.8072\n",
"Epoch 49/50\n",
"2000/2000 [==============================] - 37s 18ms/step - loss: 0.1902 - accuracy: 0.9413 - val_loss: 0.8061 - val_accuracy: 0.8070\n",
"Epoch 50/50\n",
"2000/2000 [==============================] - 36s 18ms/step - loss: 0.1894 - accuracy: 0.9416 - val_loss: 0.8051 - val_accuracy: 0.8069\n"
]
}
],
"source": [
"model.fit(\n",
" [encoder_input_data, decoder_input_data],\n",
" decoder_target_data,\n",
" batch_size=batch_size,\n",
" epochs=epochs,\n",
" validation_split=0.2,\n",
")\n",
"\n",
"model.save(\"s2s_model.keras\")"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"### Load model"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 8,
"outputs": [],
"source": [
"model = keras.models.load_model(\"s2s_model.keras\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:14:01.648294Z",
"end_time": "2024-05-30T20:14:02.463293Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Encoder model"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 9,
"outputs": [],
"source": [
"encoder_inputs = model.input[0]\n",
"encoder_outputs, state_h_enc, state_c_enc = model.layers[2].output\n",
"encoder_states = [state_h_enc, state_c_enc]\n",
"encoder_model = keras.Model(encoder_inputs, encoder_states)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:14:02.529310Z",
"end_time": "2024-05-30T20:14:02.548318Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Decoder model"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 10,
"outputs": [],
"source": [
"decoder_inputs = model.input[1]\n",
"decoder_state_input_h = keras.Input(shape=(latent_dim,))\n",
"decoder_state_input_c = keras.Input(shape=(latent_dim,))\n",
"decoder_states_inputs = [decoder_state_input_h, decoder_state_input_c]\n",
"decoder_lstm = model.layers[3]\n",
"decoder_outputs, state_h_dec, state_c_dec = decoder_lstm(\n",
" decoder_inputs, initial_state=decoder_states_inputs\n",
")\n",
"decoder_states = [state_h_dec, state_c_dec]\n",
"decoder_dense = model.layers[4]\n",
"decoder_outputs = decoder_dense(decoder_outputs)\n",
"decoder_model = keras.Model(\n",
" [decoder_inputs] + decoder_states_inputs, [decoder_outputs] + decoder_states\n",
")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:14:03.768750Z",
"end_time": "2024-05-30T20:14:03.977748Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Define the decoding sequence"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 14,
"outputs": [],
"source": [
"reverse_input_char_index = dict((i, char) for char, i in input_token_index.items())\n",
"reverse_target_char_index = dict((i, char) for char, i in target_token_index.items())\n",
"\n",
"\n",
"def decode_sequence(input_seq):\n",
" states_value = encoder_model.predict(input_seq, verbose=0)\n",
"\n",
" target_seq = np.zeros((1, 1, num_decoder_tokens))\n",
" target_seq[0, 0, target_token_index[\"\\t\"]] = 1.0\n",
"\n",
" stop_condition = False\n",
" decoded_sentence = \"\"\n",
" while not stop_condition:\n",
" output_tokens, h, c = decoder_model.predict(\n",
" [target_seq] + states_value, verbose=0\n",
" )\n",
"\n",
" sampled_token_index = np.argmax(output_tokens[0, -1, :])\n",
" sampled_char = reverse_target_char_index[sampled_token_index]\n",
" decoded_sentence += sampled_char\n",
"\n",
" if sampled_char == \"\\n\" or len(decoded_sentence) > max_decoder_seq_length:\n",
" stop_condition = True\n",
"\n",
" target_seq = np.zeros((1, 1, num_decoder_tokens))\n",
" target_seq[0, 0, sampled_token_index] = 1.0\n",
"\n",
" states_value = [h, c]\n",
" return decoded_sentence"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:15:46.635878Z",
"end_time": "2024-05-30T20:15:46.660046Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"### Sample predictions"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"start_time": "2024-05-30T20:14:08.622584Z",
"end_time": "2024-05-30T20:14:25.769685Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-\n",
"Input sentence: Go.\n",
"Decoded sentence: Idź się.\n",
"\n",
"-\n",
"Input sentence: Hi.\n",
"Decoded sentence: Cześć.\n",
"\n",
"-\n",
"Input sentence: Run!\n",
"Decoded sentence: Uciekaj!\n",
"\n",
"-\n",
"Input sentence: Run.\n",
"Decoded sentence: Biegnij.\n",
"\n",
"-\n",
"Input sentence: Run.\n",
"Decoded sentence: Biegnij.\n",
"\n",
"-\n",
"Input sentence: Who?\n",
"Decoded sentence: Kto?\n",
"\n",
"-\n",
"Input sentence: Wow!\n",
"Decoded sentence: Jak sprawdzi!\n",
"\n",
"-\n",
"Input sentence: Wow!\n",
"Decoded sentence: Jak sprawdzi!\n",
"\n",
"-\n",
"Input sentence: Duck!\n",
"Decoded sentence: Unik!\n",
"\n",
"-\n",
"Input sentence: Fire!\n",
"Decoded sentence: Staktowa!\n",
"\n",
"-\n",
"Input sentence: Fire!\n",
"Decoded sentence: Staktowa!\n",
"\n",
"-\n",
"Input sentence: Fire!\n",
"Decoded sentence: Staktowa!\n",
"\n",
"-\n",
"Input sentence: Help!\n",
"Decoded sentence: Pomocy!\n",
"\n",
"-\n",
"Input sentence: Hide.\n",
"Decoded sentence: Utekty to.\n",
"\n",
"-\n",
"Input sentence: Jump!\n",
"Decoded sentence: Samujesz!\n",
"\n",
"-\n",
"Input sentence: Jump.\n",
"Decoded sentence: Skok.\n",
"\n",
"-\n",
"Input sentence: Stay.\n",
"Decoded sentence: Zostań.\n",
"\n",
"-\n",
"Input sentence: Stop!\n",
"Decoded sentence: Zaczej się!\n",
"\n",
"-\n",
"Input sentence: Stop!\n",
"Decoded sentence: Zaczej się!\n",
"\n",
"-\n",
"Input sentence: Wait!\n",
"Decoded sentence: Czekajcie!\n",
"\n"
]
}
],
"source": [
"for seq_index in range(20):\n",
" input_seq = encoder_input_data[seq_index : seq_index + 1]\n",
" decoded_sentence = decode_sequence(input_seq)\n",
" print(\"-\")\n",
" print(\"Input sentence:\", input_texts[seq_index])\n",
" print(\"Decoded sentence:\", decoded_sentence)"
]
},
{
"cell_type": "markdown",
"source": [
"### Compute BLEU score"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 15,
"outputs": [],
"source": [
"def preprocess_text(text):\n",
" return text.strip().split()\n",
"\n",
"def compute_bleu_score(target_texts, range_limit=1000):\n",
" candidate_corpus = []\n",
" references_corpus = []\n",
"\n",
" for seq_index in tqdm(range(range_limit), desc=\"Calculating BLEU scores\"):\n",
" input_seq = encoder_input_data[seq_index : seq_index + 1]\n",
" decoded_sentence = decode_sequence(input_seq)\n",
" candidate_corpus.append(preprocess_text(decoded_sentence))\n",
" references_corpus.append([preprocess_text(target_texts[seq_index])])\n",
"\n",
" smoothie = SmoothingFunction().method4\n",
" bleu_scores = [sentence_bleu(ref, cand, smoothing_function=smoothie) for ref, cand in zip(references_corpus, candidate_corpus)]\n",
" average_bleu = sum(bleu_scores) / len(bleu_scores)\n",
"\n",
" print(\"BLEU score:\", average_bleu)\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:15:51.685004Z",
"end_time": "2024-05-30T20:15:52.898119Z"
}
}
},
{
"cell_type": "code",
"execution_count": 16,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating BLEU scores: 100%|██████████| 100/100 [01:12<00:00, 1.39it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"BLEU score: 0.2236331802292942\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"compute_bleu_score(target_texts, 100)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:15:52.901120Z",
"end_time": "2024-05-30T20:17:05.089871Z"
}
}
},
{
"cell_type": "code",
"execution_count": 17,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating BLEU scores: 100%|██████████| 1000/1000 [14:39<00:00, 1.14it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"BLEU score: 0.152040789734918\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"compute_bleu_score(target_texts, 1000)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2024-05-30T20:17:05.093838Z",
"end_time": "2024-05-30T20:31:45.072265Z"
}
}
},
{
"cell_type": "code",
"execution_count": 19,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating BLEU scores: 8%|▊ | 761/10000 [13:31<2:44:18, 1.07s/it]\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[1;31mKeyboardInterrupt\u001B[0m Traceback (most recent call last)",
"Cell \u001B[1;32mIn[19], line 1\u001B[0m\n\u001B[1;32m----> 1\u001B[0m \u001B[43mcompute_bleu_score\u001B[49m\u001B[43m(\u001B[49m\u001B[43mtarget_texts\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m10000\u001B[39;49m\u001B[43m)\u001B[49m\n",
"Cell \u001B[1;32mIn[15], line 13\u001B[0m, in \u001B[0;36mcompute_bleu_score\u001B[1;34m(target_texts, range_limit)\u001B[0m\n\u001B[0;32m 11\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m seq_index \u001B[38;5;129;01min\u001B[39;00m tqdm(\u001B[38;5;28mrange\u001B[39m(range_limit), desc\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mCalculating BLEU scores\u001B[39m\u001B[38;5;124m\"\u001B[39m):\n\u001B[0;32m 12\u001B[0m input_seq \u001B[38;5;241m=\u001B[39m encoder_input_data[seq_index : seq_index \u001B[38;5;241m+\u001B[39m \u001B[38;5;241m1\u001B[39m]\n\u001B[1;32m---> 13\u001B[0m decoded_sentence \u001B[38;5;241m=\u001B[39m \u001B[43mdecode_sequence\u001B[49m\u001B[43m(\u001B[49m\u001B[43minput_seq\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 14\u001B[0m candidate_corpus\u001B[38;5;241m.\u001B[39mappend(preprocess_text(decoded_sentence))\n\u001B[0;32m 15\u001B[0m references_corpus\u001B[38;5;241m.\u001B[39mappend([preprocess_text(target_texts[seq_index])])\n",
"Cell \u001B[1;32mIn[14], line 6\u001B[0m, in \u001B[0;36mdecode_sequence\u001B[1;34m(input_seq)\u001B[0m\n\u001B[0;32m 5\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mdecode_sequence\u001B[39m(input_seq):\n\u001B[1;32m----> 6\u001B[0m states_value \u001B[38;5;241m=\u001B[39m \u001B[43mencoder_model\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mpredict\u001B[49m\u001B[43m(\u001B[49m\u001B[43minput_seq\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mverbose\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m0\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[0;32m 8\u001B[0m target_seq \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39mzeros((\u001B[38;5;241m1\u001B[39m, \u001B[38;5;241m1\u001B[39m, num_decoder_tokens))\n\u001B[0;32m 9\u001B[0m target_seq[\u001B[38;5;241m0\u001B[39m, \u001B[38;5;241m0\u001B[39m, target_token_index[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;130;01m\\t\u001B[39;00m\u001B[38;5;124m\"\u001B[39m]] \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m1.0\u001B[39m\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\keras\\utils\\traceback_utils.py:65\u001B[0m, in \u001B[0;36mfilter_traceback.<locals>.error_handler\u001B[1;34m(*args, **kwargs)\u001B[0m\n\u001B[0;32m 63\u001B[0m filtered_tb \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m\n\u001B[0;32m 64\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m---> 65\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m fn(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m 66\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m e:\n\u001B[0;32m 67\u001B[0m filtered_tb \u001B[38;5;241m=\u001B[39m _process_traceback_frames(e\u001B[38;5;241m.\u001B[39m__traceback__)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\keras\\engine\\training.py:2220\u001B[0m, in \u001B[0;36mModel.predict\u001B[1;34m(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)\u001B[0m\n\u001B[0;32m 2211\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m:\n\u001B[0;32m 2212\u001B[0m warnings\u001B[38;5;241m.\u001B[39mwarn(\n\u001B[0;32m 2213\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mUsing Model.predict with MultiWorkerMirroredStrategy \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 2214\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mor TPUStrategy and AutoShardPolicy.FILE might lead to \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 2217\u001B[0m stacklevel\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m2\u001B[39m,\n\u001B[0;32m 2218\u001B[0m )\n\u001B[1;32m-> 2220\u001B[0m data_handler \u001B[38;5;241m=\u001B[39m \u001B[43mdata_adapter\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget_data_handler\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 2221\u001B[0m \u001B[43m \u001B[49m\u001B[43mx\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mx\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2222\u001B[0m \u001B[43m \u001B[49m\u001B[43mbatch_size\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mbatch_size\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2223\u001B[0m \u001B[43m \u001B[49m\u001B[43msteps_per_epoch\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msteps\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2224\u001B[0m \u001B[43m \u001B[49m\u001B[43minitial_epoch\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m0\u001B[39;49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2225\u001B[0m \u001B[43m \u001B[49m\u001B[43mepochs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2226\u001B[0m \u001B[43m \u001B[49m\u001B[43mmax_queue_size\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mmax_queue_size\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2227\u001B[0m \u001B[43m \u001B[49m\u001B[43mworkers\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mworkers\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2228\u001B[0m \u001B[43m \u001B[49m\u001B[43muse_multiprocessing\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43muse_multiprocessing\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2229\u001B[0m \u001B[43m \u001B[49m\u001B[43mmodel\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2230\u001B[0m \u001B[43m \u001B[49m\u001B[43msteps_per_execution\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_steps_per_execution\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2231\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 2233\u001B[0m \u001B[38;5;66;03m# Container that configures and calls `tf.keras.Callback`s.\u001B[39;00m\n\u001B[0;32m 2234\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(callbacks, callbacks_module\u001B[38;5;241m.\u001B[39mCallbackList):\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\keras\\engine\\data_adapter.py:1582\u001B[0m, in \u001B[0;36mget_data_handler\u001B[1;34m(*args, **kwargs)\u001B[0m\n\u001B[0;32m 1580\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mgetattr\u001B[39m(kwargs[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mmodel\u001B[39m\u001B[38;5;124m\"\u001B[39m], \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m_cluster_coordinator\u001B[39m\u001B[38;5;124m\"\u001B[39m, \u001B[38;5;28;01mNone\u001B[39;00m):\n\u001B[0;32m 1581\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m _ClusterCoordinatorDataHandler(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[1;32m-> 1582\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m DataHandler(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\keras\\engine\\data_adapter.py:1262\u001B[0m, in \u001B[0;36mDataHandler.__init__\u001B[1;34m(self, x, y, sample_weight, batch_size, steps_per_epoch, initial_epoch, epochs, shuffle, class_weight, max_queue_size, workers, use_multiprocessing, model, steps_per_execution, distribute)\u001B[0m\n\u001B[0;32m 1259\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_steps_per_execution \u001B[38;5;241m=\u001B[39m steps_per_execution\n\u001B[0;32m 1261\u001B[0m adapter_cls \u001B[38;5;241m=\u001B[39m select_data_adapter(x, y)\n\u001B[1;32m-> 1262\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_adapter \u001B[38;5;241m=\u001B[39m \u001B[43madapter_cls\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 1263\u001B[0m \u001B[43m \u001B[49m\u001B[43mx\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1264\u001B[0m \u001B[43m \u001B[49m\u001B[43my\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1265\u001B[0m \u001B[43m \u001B[49m\u001B[43mbatch_size\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mbatch_size\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1266\u001B[0m \u001B[43m \u001B[49m\u001B[43msteps\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msteps_per_epoch\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1267\u001B[0m \u001B[43m \u001B[49m\u001B[43mepochs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mepochs\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m-\u001B[39;49m\u001B[43m \u001B[49m\u001B[43minitial_epoch\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1268\u001B[0m \u001B[43m \u001B[49m\u001B[43msample_weights\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msample_weight\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1269\u001B[0m \u001B[43m \u001B[49m\u001B[43mshuffle\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mshuffle\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1270\u001B[0m \u001B[43m \u001B[49m\u001B[43mmax_queue_size\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mmax_queue_size\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1271\u001B[0m \u001B[43m \u001B[49m\u001B[43mworkers\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mworkers\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1272\u001B[0m \u001B[43m \u001B[49m\u001B[43muse_multiprocessing\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43muse_multiprocessing\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1273\u001B[0m \u001B[43m \u001B[49m\u001B[43mdistribution_strategy\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mtf\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mdistribute\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget_strategy\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1274\u001B[0m \u001B[43m \u001B[49m\u001B[43mmodel\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mmodel\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 1275\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 1277\u001B[0m strategy \u001B[38;5;241m=\u001B[39m tf\u001B[38;5;241m.\u001B[39mdistribute\u001B[38;5;241m.\u001B[39mget_strategy()\n\u001B[0;32m 1279\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_current_step \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m0\u001B[39m\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\keras\\engine\\data_adapter.py:347\u001B[0m, in \u001B[0;36mTensorLikeDataAdapter.__init__\u001B[1;34m(self, x, y, sample_weights, sample_weight_modes, batch_size, epochs, steps, shuffle, **kwargs)\u001B[0m\n\u001B[0;32m 344\u001B[0m flat_dataset \u001B[38;5;241m=\u001B[39m flat_dataset\u001B[38;5;241m.\u001B[39mshuffle(\u001B[38;5;241m1024\u001B[39m)\u001B[38;5;241m.\u001B[39mrepeat(epochs)\n\u001B[0;32m 345\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m flat_dataset\n\u001B[1;32m--> 347\u001B[0m indices_dataset \u001B[38;5;241m=\u001B[39m \u001B[43mindices_dataset\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mflat_map\u001B[49m\u001B[43m(\u001B[49m\u001B[43mslice_batch_indices\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 349\u001B[0m dataset \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mslice_inputs(indices_dataset, inputs)\n\u001B[0;32m 351\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m shuffle \u001B[38;5;241m==\u001B[39m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mbatch\u001B[39m\u001B[38;5;124m\"\u001B[39m:\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\data\\ops\\dataset_ops.py:2245\u001B[0m, in \u001B[0;36mDatasetV2.flat_map\u001B[1;34m(self, map_func, name)\u001B[0m\n\u001B[0;32m 2212\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mflat_map\u001B[39m(\u001B[38;5;28mself\u001B[39m, map_func, name\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m):\n\u001B[0;32m 2213\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Maps `map_func` across this dataset and flattens the result.\u001B[39;00m\n\u001B[0;32m 2214\u001B[0m \n\u001B[0;32m 2215\u001B[0m \u001B[38;5;124;03m The type signature is:\u001B[39;00m\n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 2243\u001B[0m \u001B[38;5;124;03m Dataset: A `Dataset`.\u001B[39;00m\n\u001B[0;32m 2244\u001B[0m \u001B[38;5;124;03m \"\"\"\u001B[39;00m\n\u001B[1;32m-> 2245\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mFlatMapDataset\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mmap_func\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mname\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\data\\ops\\dataset_ops.py:5484\u001B[0m, in \u001B[0;36mFlatMapDataset.__init__\u001B[1;34m(self, input_dataset, map_func, name)\u001B[0m\n\u001B[0;32m 5482\u001B[0m \u001B[38;5;250m\u001B[39m\u001B[38;5;124;03m\"\"\"See `Dataset.flat_map()` for details.\"\"\"\u001B[39;00m\n\u001B[0;32m 5483\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_input_dataset \u001B[38;5;241m=\u001B[39m input_dataset\n\u001B[1;32m-> 5484\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_map_func \u001B[38;5;241m=\u001B[39m \u001B[43mstructured_function\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mStructuredFunctionWrapper\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 5485\u001B[0m \u001B[43m \u001B[49m\u001B[43mmap_func\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_transformation_name\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mdataset\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43minput_dataset\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 5486\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_map_func\u001B[38;5;241m.\u001B[39moutput_structure, DatasetSpec):\n\u001B[0;32m 5487\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mTypeError\u001B[39;00m(\n\u001B[0;32m 5488\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mThe `map_func` argument must return a `Dataset` object. Got \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 5489\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00m_get_type(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_map_func\u001B[38;5;241m.\u001B[39moutput_structure)\u001B[38;5;132;01m!r}\u001B[39;00m\u001B[38;5;124m.\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\data\\ops\\structured_function.py:271\u001B[0m, in \u001B[0;36mStructuredFunctionWrapper.__init__\u001B[1;34m(self, func, transformation_name, dataset, input_classes, input_shapes, input_types, input_structure, add_to_graph, use_legacy_function, defun_kwargs)\u001B[0m\n\u001B[0;32m 264\u001B[0m warnings\u001B[38;5;241m.\u001B[39mwarn(\n\u001B[0;32m 265\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mEven though the `tf.config.experimental_run_functions_eagerly` \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 266\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124moption is set, this option does not apply to tf.data functions. \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 267\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mTo force eager execution of tf.data functions, please use \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 268\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m`tf.data.experimental.enable_debug_mode()`.\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 269\u001B[0m fn_factory \u001B[38;5;241m=\u001B[39m trace_tf_function(defun_kwargs)\n\u001B[1;32m--> 271\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_function \u001B[38;5;241m=\u001B[39m \u001B[43mfn_factory\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 272\u001B[0m \u001B[38;5;66;03m# There is no graph to add in eager mode.\u001B[39;00m\n\u001B[0;32m 273\u001B[0m add_to_graph \u001B[38;5;241m&\u001B[39m\u001B[38;5;241m=\u001B[39m \u001B[38;5;129;01mnot\u001B[39;00m context\u001B[38;5;241m.\u001B[39mexecuting_eagerly()\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\eager\\function.py:2610\u001B[0m, in \u001B[0;36mFunction.get_concrete_function\u001B[1;34m(self, *args, **kwargs)\u001B[0m\n\u001B[0;32m 2601\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mget_concrete_function\u001B[39m(\u001B[38;5;28mself\u001B[39m, \u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs):\n\u001B[0;32m 2602\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Returns a `ConcreteFunction` specialized to inputs and execution context.\u001B[39;00m\n\u001B[0;32m 2603\u001B[0m \n\u001B[0;32m 2604\u001B[0m \u001B[38;5;124;03m Args:\u001B[39;00m\n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 2608\u001B[0m \u001B[38;5;124;03m or `tf.Tensor` or `tf.TensorSpec`.\u001B[39;00m\n\u001B[0;32m 2609\u001B[0m \u001B[38;5;124;03m \"\"\"\u001B[39;00m\n\u001B[1;32m-> 2610\u001B[0m graph_function \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_get_concrete_function_garbage_collected(\n\u001B[0;32m 2611\u001B[0m \u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m 2612\u001B[0m graph_function\u001B[38;5;241m.\u001B[39m_garbage_collector\u001B[38;5;241m.\u001B[39mrelease() \u001B[38;5;66;03m# pylint: disable=protected-access\u001B[39;00m\n\u001B[0;32m 2613\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m graph_function\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\eager\\function.py:2576\u001B[0m, in \u001B[0;36mFunction._get_concrete_function_garbage_collected\u001B[1;34m(self, *args, **kwargs)\u001B[0m\n\u001B[0;32m 2574\u001B[0m args, kwargs \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m, \u001B[38;5;28;01mNone\u001B[39;00m\n\u001B[0;32m 2575\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_lock:\n\u001B[1;32m-> 2576\u001B[0m graph_function, _ \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_maybe_define_function\u001B[49m\u001B[43m(\u001B[49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 2577\u001B[0m seen_names \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mset\u001B[39m()\n\u001B[0;32m 2578\u001B[0m captured \u001B[38;5;241m=\u001B[39m object_identity\u001B[38;5;241m.\u001B[39mObjectIdentitySet(\n\u001B[0;32m 2579\u001B[0m graph_function\u001B[38;5;241m.\u001B[39mgraph\u001B[38;5;241m.\u001B[39minternal_captures)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\eager\\function.py:2760\u001B[0m, in \u001B[0;36mFunction._maybe_define_function\u001B[1;34m(self, args, kwargs)\u001B[0m\n\u001B[0;32m 2758\u001B[0m \u001B[38;5;66;03m# Only get placeholders for arguments, not captures\u001B[39;00m\n\u001B[0;32m 2759\u001B[0m args, kwargs \u001B[38;5;241m=\u001B[39m placeholder_dict[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124margs\u001B[39m\u001B[38;5;124m\"\u001B[39m]\n\u001B[1;32m-> 2760\u001B[0m graph_function \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_create_graph_function\u001B[49m\u001B[43m(\u001B[49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 2762\u001B[0m graph_capture_container \u001B[38;5;241m=\u001B[39m graph_function\u001B[38;5;241m.\u001B[39mgraph\u001B[38;5;241m.\u001B[39m_capture_func_lib \u001B[38;5;66;03m# pylint: disable=protected-access\u001B[39;00m\n\u001B[0;32m 2763\u001B[0m \u001B[38;5;66;03m# Maintain the list of all captures\u001B[39;00m\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\eager\\function.py:2670\u001B[0m, in \u001B[0;36mFunction._create_graph_function\u001B[1;34m(self, args, kwargs)\u001B[0m\n\u001B[0;32m 2665\u001B[0m missing_arg_names \u001B[38;5;241m=\u001B[39m [\n\u001B[0;32m 2666\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m%s\u001B[39;00m\u001B[38;5;124m_\u001B[39m\u001B[38;5;132;01m%d\u001B[39;00m\u001B[38;5;124m\"\u001B[39m \u001B[38;5;241m%\u001B[39m (arg, i) \u001B[38;5;28;01mfor\u001B[39;00m i, arg \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28menumerate\u001B[39m(missing_arg_names)\n\u001B[0;32m 2667\u001B[0m ]\n\u001B[0;32m 2668\u001B[0m arg_names \u001B[38;5;241m=\u001B[39m base_arg_names \u001B[38;5;241m+\u001B[39m missing_arg_names\n\u001B[0;32m 2669\u001B[0m graph_function \u001B[38;5;241m=\u001B[39m ConcreteFunction(\n\u001B[1;32m-> 2670\u001B[0m \u001B[43mfunc_graph_module\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mfunc_graph_from_py_func\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 2671\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_name\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2672\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_python_function\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2673\u001B[0m \u001B[43m \u001B[49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2674\u001B[0m \u001B[43m \u001B[49m\u001B[43mkwargs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2675\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43minput_signature\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2676\u001B[0m \u001B[43m \u001B[49m\u001B[43mautograph\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_autograph\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2677\u001B[0m \u001B[43m \u001B[49m\u001B[43mautograph_options\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_autograph_options\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2678\u001B[0m \u001B[43m \u001B[49m\u001B[43marg_names\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43marg_names\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 2679\u001B[0m \u001B[43m \u001B[49m\u001B[43mcapture_by_value\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_capture_by_value\u001B[49m\u001B[43m)\u001B[49m,\n\u001B[0;32m 2680\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_function_attributes,\n\u001B[0;32m 2681\u001B[0m spec\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mfunction_spec,\n\u001B[0;32m 2682\u001B[0m \u001B[38;5;66;03m# Tell the ConcreteFunction to clean up its graph once it goes out of\u001B[39;00m\n\u001B[0;32m 2683\u001B[0m \u001B[38;5;66;03m# scope. This is not the default behavior since it gets used in some\u001B[39;00m\n\u001B[0;32m 2684\u001B[0m \u001B[38;5;66;03m# places (like Keras) where the FuncGraph lives longer than the\u001B[39;00m\n\u001B[0;32m 2685\u001B[0m \u001B[38;5;66;03m# ConcreteFunction.\u001B[39;00m\n\u001B[0;32m 2686\u001B[0m shared_func_graph\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m)\n\u001B[0;32m 2687\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m graph_function\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\func_graph.py:1251\u001B[0m, in \u001B[0;36mfunc_graph_from_py_func\u001B[1;34m(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, acd_record_initial_resource_uses)\u001B[0m\n\u001B[0;32m 1247\u001B[0m func_outputs \u001B[38;5;241m=\u001B[39m python_func(\u001B[38;5;241m*\u001B[39mfunc_args, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mfunc_kwargs)\n\u001B[0;32m 1249\u001B[0m \u001B[38;5;66;03m# invariant: `func_outputs` contains only Tensors, CompositeTensors,\u001B[39;00m\n\u001B[0;32m 1250\u001B[0m \u001B[38;5;66;03m# TensorArrays and `None`s.\u001B[39;00m\n\u001B[1;32m-> 1251\u001B[0m func_outputs \u001B[38;5;241m=\u001B[39m \u001B[43mnest\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mmap_structure\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 1252\u001B[0m \u001B[43m \u001B[49m\u001B[43mconvert\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mfunc_outputs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexpand_composites\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mTrue\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[0;32m 1254\u001B[0m check_func_mutation(func_args_before, func_kwargs_before, func_args,\n\u001B[0;32m 1255\u001B[0m func_kwargs, original_func)\n\u001B[0;32m 1256\u001B[0m \u001B[38;5;28;01mfinally\u001B[39;00m:\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\util\\nest.py:917\u001B[0m, in \u001B[0;36mmap_structure\u001B[1;34m(func, *structure, **kwargs)\u001B[0m\n\u001B[0;32m 913\u001B[0m flat_structure \u001B[38;5;241m=\u001B[39m (flatten(s, expand_composites) \u001B[38;5;28;01mfor\u001B[39;00m s \u001B[38;5;129;01min\u001B[39;00m structure)\n\u001B[0;32m 914\u001B[0m entries \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mzip\u001B[39m(\u001B[38;5;241m*\u001B[39mflat_structure)\n\u001B[0;32m 916\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m pack_sequence_as(\n\u001B[1;32m--> 917\u001B[0m structure[\u001B[38;5;241m0\u001B[39m], [func(\u001B[38;5;241m*\u001B[39mx) \u001B[38;5;28;01mfor\u001B[39;00m x \u001B[38;5;129;01min\u001B[39;00m entries],\n\u001B[0;32m 918\u001B[0m expand_composites\u001B[38;5;241m=\u001B[39mexpand_composites)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\util\\nest.py:917\u001B[0m, in \u001B[0;36m<listcomp>\u001B[1;34m(.0)\u001B[0m\n\u001B[0;32m 913\u001B[0m flat_structure \u001B[38;5;241m=\u001B[39m (flatten(s, expand_composites) \u001B[38;5;28;01mfor\u001B[39;00m s \u001B[38;5;129;01min\u001B[39;00m structure)\n\u001B[0;32m 914\u001B[0m entries \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mzip\u001B[39m(\u001B[38;5;241m*\u001B[39mflat_structure)\n\u001B[0;32m 916\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m pack_sequence_as(\n\u001B[1;32m--> 917\u001B[0m structure[\u001B[38;5;241m0\u001B[39m], [\u001B[43mfunc\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mx\u001B[49m\u001B[43m)\u001B[49m \u001B[38;5;28;01mfor\u001B[39;00m x \u001B[38;5;129;01min\u001B[39;00m entries],\n\u001B[0;32m 918\u001B[0m expand_composites\u001B[38;5;241m=\u001B[39mexpand_composites)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\func_graph.py:1210\u001B[0m, in \u001B[0;36mfunc_graph_from_py_func.<locals>.convert\u001B[1;34m(x)\u001B[0m\n\u001B[0;32m 1203\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mTypeError\u001B[39;00m(\n\u001B[0;32m 1204\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mTo be compatible with tf.function, Python functions \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 1205\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mmust return zero or more Tensors or ExtensionTypes or None \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 1206\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mvalues; in compilation of \u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mstr\u001B[39m(python_func)\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m, found return \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 1207\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mvalue of type \u001B[39m\u001B[38;5;132;01m{\u001B[39;00m\u001B[38;5;28mtype\u001B[39m(x)\u001B[38;5;241m.\u001B[39m\u001B[38;5;18m__name__\u001B[39m\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m, which is not a Tensor or \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 1208\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mExtensionType.\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 1209\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m add_control_dependencies:\n\u001B[1;32m-> 1210\u001B[0m x \u001B[38;5;241m=\u001B[39m \u001B[43mdeps_ctx\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mmark_as_return\u001B[49m\u001B[43m(\u001B[49m\u001B[43mx\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 1211\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m x\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\auto_control_deps.py:249\u001B[0m, in \u001B[0;36mAutomaticControlDependencies.mark_as_return\u001B[1;34m(self, tensor)\u001B[0m\n\u001B[0;32m 244\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m tensor_array_ops\u001B[38;5;241m.\u001B[39mbuild_ta_with_new_flow(tensor, flow)\n\u001B[0;32m 245\u001B[0m \u001B[38;5;66;03m# We want to make the return values depend on the stateful operations, but\u001B[39;00m\n\u001B[0;32m 246\u001B[0m \u001B[38;5;66;03m# we don't want to introduce a cycle, so we make the return value the result\u001B[39;00m\n\u001B[0;32m 247\u001B[0m \u001B[38;5;66;03m# of a new identity operation that the stateful operations definitely don't\u001B[39;00m\n\u001B[0;32m 248\u001B[0m \u001B[38;5;66;03m# depend on.\u001B[39;00m\n\u001B[1;32m--> 249\u001B[0m tensor \u001B[38;5;241m=\u001B[39m \u001B[43marray_ops\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43midentity\u001B[49m\u001B[43m(\u001B[49m\u001B[43mtensor\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 250\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_returned_tensors\u001B[38;5;241m.\u001B[39madd(tensor)\n\u001B[0;32m 251\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m tensor\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\util\\traceback_utils.py:150\u001B[0m, in \u001B[0;36mfilter_traceback.<locals>.error_handler\u001B[1;34m(*args, **kwargs)\u001B[0m\n\u001B[0;32m 148\u001B[0m filtered_tb \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m\n\u001B[0;32m 149\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 150\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m fn(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m 151\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m e:\n\u001B[0;32m 152\u001B[0m filtered_tb \u001B[38;5;241m=\u001B[39m _process_traceback_frames(e\u001B[38;5;241m.\u001B[39m__traceback__)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\util\\dispatch.py:1176\u001B[0m, in \u001B[0;36madd_dispatch_support.<locals>.decorator.<locals>.op_dispatch_handler\u001B[1;34m(*args, **kwargs)\u001B[0m\n\u001B[0;32m 1174\u001B[0m \u001B[38;5;66;03m# Fallback dispatch system (dispatch v1):\u001B[39;00m\n\u001B[0;32m 1175\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m-> 1176\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m dispatch_target(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m 1177\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m (\u001B[38;5;167;01mTypeError\u001B[39;00m, \u001B[38;5;167;01mValueError\u001B[39;00m):\n\u001B[0;32m 1178\u001B[0m \u001B[38;5;66;03m# Note: convert_to_eager_tensor currently raises a ValueError, not a\u001B[39;00m\n\u001B[0;32m 1179\u001B[0m \u001B[38;5;66;03m# TypeError, when given unexpected types. So we need to catch both.\u001B[39;00m\n\u001B[0;32m 1180\u001B[0m result \u001B[38;5;241m=\u001B[39m dispatch(op_dispatch_handler, args, kwargs)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\ops\\array_ops.py:294\u001B[0m, in \u001B[0;36midentity\u001B[1;34m(input, name)\u001B[0m\n\u001B[0;32m 290\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m context\u001B[38;5;241m.\u001B[39mexecuting_eagerly() \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28mhasattr\u001B[39m(\u001B[38;5;28minput\u001B[39m, \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mgraph\u001B[39m\u001B[38;5;124m\"\u001B[39m):\n\u001B[0;32m 291\u001B[0m \u001B[38;5;66;03m# Make sure we get an input with handle data attached from resource\u001B[39;00m\n\u001B[0;32m 292\u001B[0m \u001B[38;5;66;03m# variables. Variables have correct handle data when graph building.\u001B[39;00m\n\u001B[0;32m 293\u001B[0m \u001B[38;5;28minput\u001B[39m \u001B[38;5;241m=\u001B[39m ops\u001B[38;5;241m.\u001B[39mconvert_to_tensor(\u001B[38;5;28minput\u001B[39m)\n\u001B[1;32m--> 294\u001B[0m ret \u001B[38;5;241m=\u001B[39m \u001B[43mgen_array_ops\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43midentity\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43minput\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mname\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 295\u001B[0m \u001B[38;5;66;03m# Propagate handle data for happier shape inference for resource variables.\u001B[39;00m\n\u001B[0;32m 296\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mhasattr\u001B[39m(\u001B[38;5;28minput\u001B[39m, \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m_handle_data\u001B[39m\u001B[38;5;124m\"\u001B[39m):\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\ops\\gen_array_ops.py:4081\u001B[0m, in \u001B[0;36midentity\u001B[1;34m(input, name)\u001B[0m\n\u001B[0;32m 4079\u001B[0m \u001B[38;5;28;01mpass\u001B[39;00m \u001B[38;5;66;03m# Add nodes to the TensorFlow graph.\u001B[39;00m\n\u001B[0;32m 4080\u001B[0m \u001B[38;5;66;03m# Add nodes to the TensorFlow graph.\u001B[39;00m\n\u001B[1;32m-> 4081\u001B[0m _, _, _op, _outputs \u001B[38;5;241m=\u001B[39m \u001B[43m_op_def_library\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_apply_op_helper\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 4082\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mIdentity\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;28;43minput\u001B[39;49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43minput\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mname\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 4083\u001B[0m _result \u001B[38;5;241m=\u001B[39m _outputs[:]\n\u001B[0;32m 4084\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m _execute\u001B[38;5;241m.\u001B[39mmust_record_gradient():\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\op_def_library.py:797\u001B[0m, in \u001B[0;36m_apply_op_helper\u001B[1;34m(op_type_name, name, **keywords)\u001B[0m\n\u001B[0;32m 792\u001B[0m must_colocate_inputs \u001B[38;5;241m=\u001B[39m [val \u001B[38;5;28;01mfor\u001B[39;00m arg, val \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mzip\u001B[39m(op_def\u001B[38;5;241m.\u001B[39minput_arg, inputs)\n\u001B[0;32m 793\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m arg\u001B[38;5;241m.\u001B[39mis_ref]\n\u001B[0;32m 794\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m _MaybeColocateWith(must_colocate_inputs):\n\u001B[0;32m 795\u001B[0m \u001B[38;5;66;03m# Add Op to graph\u001B[39;00m\n\u001B[0;32m 796\u001B[0m \u001B[38;5;66;03m# pylint: disable=protected-access\u001B[39;00m\n\u001B[1;32m--> 797\u001B[0m op \u001B[38;5;241m=\u001B[39m \u001B[43mg\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_create_op_internal\u001B[49m\u001B[43m(\u001B[49m\u001B[43mop_type_name\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43minputs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mdtypes\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mNone\u001B[39;49;00m\u001B[43m,\u001B[49m\n\u001B[0;32m 798\u001B[0m \u001B[43m \u001B[49m\u001B[43mname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mscope\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43minput_types\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43minput_types\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 799\u001B[0m \u001B[43m \u001B[49m\u001B[43mattrs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mattr_protos\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mop_def\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mop_def\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 801\u001B[0m \u001B[38;5;66;03m# `outputs` is returned as a separate return value so that the output\u001B[39;00m\n\u001B[0;32m 802\u001B[0m \u001B[38;5;66;03m# tensors can the `op` per se can be decoupled so that the\u001B[39;00m\n\u001B[0;32m 803\u001B[0m \u001B[38;5;66;03m# `op_callbacks` can function properly. See framework/op_callbacks.py\u001B[39;00m\n\u001B[0;32m 804\u001B[0m \u001B[38;5;66;03m# for more details.\u001B[39;00m\n\u001B[0;32m 805\u001B[0m outputs \u001B[38;5;241m=\u001B[39m op\u001B[38;5;241m.\u001B[39moutputs\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\func_graph.py:735\u001B[0m, in \u001B[0;36mFuncGraph._create_op_internal\u001B[1;34m(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_device)\u001B[0m\n\u001B[0;32m 733\u001B[0m inp \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mcapture(inp)\n\u001B[0;32m 734\u001B[0m captured_inputs\u001B[38;5;241m.\u001B[39mappend(inp)\n\u001B[1;32m--> 735\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43msuper\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43mFuncGraph\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[43m)\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_create_op_internal\u001B[49m\u001B[43m(\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;66;43;03m# pylint: disable=protected-access\u001B[39;49;00m\n\u001B[0;32m 736\u001B[0m \u001B[43m \u001B[49m\u001B[43mop_type\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mcaptured_inputs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mdtypes\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43minput_types\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mname\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mattrs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mop_def\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 737\u001B[0m \u001B[43m \u001B[49m\u001B[43mcompute_device\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\ops.py:3800\u001B[0m, in \u001B[0;36mGraph._create_op_internal\u001B[1;34m(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_device)\u001B[0m\n\u001B[0;32m 3797\u001B[0m \u001B[38;5;66;03m# _create_op_helper mutates the new Operation. `_mutation_lock` ensures a\u001B[39;00m\n\u001B[0;32m 3798\u001B[0m \u001B[38;5;66;03m# Session.run call cannot occur between creating and mutating the op.\u001B[39;00m\n\u001B[0;32m 3799\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_mutation_lock():\n\u001B[1;32m-> 3800\u001B[0m ret \u001B[38;5;241m=\u001B[39m \u001B[43mOperation\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 3801\u001B[0m \u001B[43m \u001B[49m\u001B[43mnode_def\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3802\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3803\u001B[0m \u001B[43m \u001B[49m\u001B[43minputs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43minputs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3804\u001B[0m \u001B[43m \u001B[49m\u001B[43moutput_types\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mdtypes\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3805\u001B[0m \u001B[43m \u001B[49m\u001B[43mcontrol_inputs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mcontrol_inputs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3806\u001B[0m \u001B[43m \u001B[49m\u001B[43minput_types\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43minput_types\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3807\u001B[0m \u001B[43m \u001B[49m\u001B[43moriginal_op\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_default_original_op\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 3808\u001B[0m \u001B[43m \u001B[49m\u001B[43mop_def\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mop_def\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 3809\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_create_op_helper(ret, compute_device\u001B[38;5;241m=\u001B[39mcompute_device)\n\u001B[0;32m 3810\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m ret\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\ops.py:2108\u001B[0m, in \u001B[0;36mOperation.__init__\u001B[1;34m(***failed resolving arguments***)\u001B[0m\n\u001B[0;32m 2105\u001B[0m control_input_ops\u001B[38;5;241m.\u001B[39mappend(control_op)\n\u001B[0;32m 2107\u001B[0m \u001B[38;5;66;03m# Initialize c_op from node_def and other inputs\u001B[39;00m\n\u001B[1;32m-> 2108\u001B[0m c_op \u001B[38;5;241m=\u001B[39m \u001B[43m_create_c_op\u001B[49m\u001B[43m(\u001B[49m\u001B[43mg\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mnode_def\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43minputs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mcontrol_input_ops\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mop_def\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mop_def\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 2109\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_init_from_c_op(c_op\u001B[38;5;241m=\u001B[39mc_op, g\u001B[38;5;241m=\u001B[39mg)\n\u001B[0;32m 2111\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_original_op \u001B[38;5;241m=\u001B[39m original_op\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\util\\traceback_utils.py:150\u001B[0m, in \u001B[0;36mfilter_traceback.<locals>.error_handler\u001B[1;34m(*args, **kwargs)\u001B[0m\n\u001B[0;32m 148\u001B[0m filtered_tb \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m\n\u001B[0;32m 149\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 150\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m fn(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m 151\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m e:\n\u001B[0;32m 152\u001B[0m filtered_tb \u001B[38;5;241m=\u001B[39m _process_traceback_frames(e\u001B[38;5;241m.\u001B[39m__traceback__)\n",
"File \u001B[1;32m~\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\tensorflow\\python\\framework\\ops.py:1966\u001B[0m, in \u001B[0;36m_create_c_op\u001B[1;34m(graph, node_def, inputs, control_inputs, op_def, extract_traceback)\u001B[0m\n\u001B[0;32m 1962\u001B[0m pywrap_tf_session\u001B[38;5;241m.\u001B[39mTF_SetAttrValueProto(op_desc, compat\u001B[38;5;241m.\u001B[39mas_str(name),\n\u001B[0;32m 1963\u001B[0m serialized)\n\u001B[0;32m 1965\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m-> 1966\u001B[0m c_op \u001B[38;5;241m=\u001B[39m \u001B[43mpywrap_tf_session\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mTF_FinishOperation\u001B[49m\u001B[43m(\u001B[49m\u001B[43mop_desc\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 1967\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m errors\u001B[38;5;241m.\u001B[39mInvalidArgumentError \u001B[38;5;28;01mas\u001B[39;00m e:\n\u001B[0;32m 1968\u001B[0m \u001B[38;5;66;03m# Convert to ValueError for backwards compatibility.\u001B[39;00m\n\u001B[0;32m 1969\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(e\u001B[38;5;241m.\u001B[39mmessage)\n",
"\u001B[1;31mKeyboardInterrupt\u001B[0m: "
]
}
],
"source": [
"compute_bleu_score(target_texts, 10000)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"Patrząc na czas wykonywania się poszczególnych kroków, uczenie modelu przez kilka godzin, blue dla wszystkich elementów powyżej 8 godzin bez rezultatów, porzuciłem dalsze próby i przeszedłem na rozwiązanie na pyTorch, które wykonało się diametralnie szybciej (oba na cuda)"
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}