{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-05-21T23:26:56.989595Z","iopub.execute_input":"2023-05-21T23:26:56.990247Z","iopub.status.idle":"2023-05-21T23:26:56.99798Z","shell.execute_reply.started":"2023-05-21T23:26:56.990205Z","shell.execute_reply":"2023-05-21T23:26:56.996319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.layers import Input, Dense, LSTM, Embedding, Dropout\nfrom tensorflow.keras.models import Model\nimport nltk\nnltk.download('punkt')\n","metadata":{"execution":{"iopub.status.busy":"2023-05-21T23:26:57.009258Z","iopub.execute_input":"2023-05-21T23:26:57.009703Z","iopub.status.idle":"2023-05-21T23:26:57.204592Z","shell.execute_reply.started":"2023-05-21T23:26:57.009664Z","shell.execute_reply":"2023-05-21T23:26:57.203055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = # cargar datos de entrenamiento\nval_data = # cargar datos de validación\n","metadata":{"execution":{"iopub.status.busy":"2023-05-21T23:26:57.206788Z","iopub.execute_input":"2023-05-21T23:26:57.207246Z","iopub.status.idle":"2023-05-21T23:26:57.21691Z","shell.execute_reply.started":"2023-05-21T23:26:57.207208Z","shell.execute_reply":"2023-05-21T23:26:57.214927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_text = [nltk.word_tokenize(desc) for desc in train_data['descriptions']]\ntrain_pos = [nltk.pos_tag(tokens) for tokens in train_text]\n\nval_text = [nltk.word_tokenize(desc) for desc in val_data['descriptions']]\nval_pos = [nltk.pos_tag(tokens) for tokens in val_text]\n","metadata":{"execution":{"iopub.status.busy":"2023-05-21T23:26:57.217952Z","iopub.status.idle":"2023-05-21T23:26:57.218463Z","shell.execute_reply.started":"2023-05-21T23:26:57.218213Z","shell.execute_reply":"2023-05-21T23:26:57.218236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"input_layer = Input(shape=(img_width, img_height, img_channels))\nx = # procesamiento de la imagen utilizando capas convolucionales\n\nembedding_layer = Embedding(vocab_size, embedding_size)(input_text)\nlstm_layer = LSTM(lstm_units)(embedding_layer)\n\noutput_layer = Dense(num_classes, activation='softmax')(lstm_layer)\n\nmodel = Model(inputs=[input_layer, input_text], outputs=output_layer)\n","metadata":{"execution":{"iopub.status.busy":"2023-05-21T23:26:57.221741Z","iopub.status.idle":"2023-05-21T23:26:57.222212Z","shell.execute_reply.started":"2023-05-21T23:26:57.221977Z","shell.execute_reply":"2023-05-21T23:26:57.222015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n\nmodel.fit([train_images, train_text], train_labels, epochs=num_epochs, validation_data=([val_images, val_text], val_labels))\n","metadata":{"execution":{"iopub.status.busy":"2023-05-21T23:26:57.223507Z","iopub.status.idle":"2023-05-21T23:26:57.223879Z","shell.execute_reply.started":"2023-05-21T23:26:57.223703Z","shell.execute_reply":"2023-05-21T23:26:57.223722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"results = model.evaluate([val_images, val_text], val_labels)\n","metadata":{"execution":{"iopub.status.busy":"2023-05-21T23:26:57.225687Z","iopub.status.idle":"2023-05-21T23:26:57.226085Z","shell.execute_reply.started":"2023-05-21T23:26:57.225888Z","shell.execute_reply":"2023-05-21T23:26:57.225908Z"},"trusted":true},"execution_count":null,"outputs":[]}]}