{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import tensorflow as tf\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\"GPU disponible:\", tf.config.list_physical_devices('GPU'))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "N = 10000 # muestras\n", "T = 30 # pasos de tiempo\n", "F = 10 # features\n", "\n", "X = np.random.rand(N, T, F)\n", "y = np.random.rand(N, 1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tensorflow.keras.models import Sequential\n", "from tensorflow.keras.layers import LSTM, Dense\n", "\n", "model = Sequential([\n", " LSTM(64, input_shape=(T, F)),\n", " Dense(1)\n", "])\n", "\n", "model.compile(optimizer='adam', loss='mse')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "history = model.fit(X, y, epochs=5, batch_size=64)\n", "\n", "# 6. Graficar pérdida\n", "plt.plot(history.history['loss'])\n", "plt.title('Pérdida de entrenamiento')\n", "plt.xlabel('Época')\n", "plt.ylabel('Loss')\n", "plt.grid(True)\n", "plt.show()\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 2 }