-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6811494
commit f09c239
Showing
9 changed files
with
3,068 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,343 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"name": "01-general-info_colab.ipynb", | ||
"provenance": [], | ||
"collapsed_sections": [] | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.8.3" | ||
}, | ||
"accelerator": "GPU" | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "KdUFcDsdzRyw" | ||
}, | ||
"source": [ | ||
"# Clonamos el repositorio para obtener los dataSet" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"colab_type": "code", | ||
"id": "mHReFf3_y9ms", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"!git clone https://github.com/joanby/tensorflow.git" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "vNKZXgtKzU2x" | ||
}, | ||
"source": [ | ||
"# Damos acceso a nuestro Drive" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"colab_type": "code", | ||
"id": "5gu7KWnzzUQ0", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"from google.colab import drive\n", | ||
"drive.mount('/content/drive')" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "1gUxIkHWzfHV" | ||
}, | ||
"source": [ | ||
"# Test it" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"colab_type": "code", | ||
"id": "mIQt3jBMzYRE", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"!ls '/content/drive/My Drive' " | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "mHsK36uN0XB-" | ||
}, | ||
"source": [ | ||
"# Google colab tools" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"colab_type": "code", | ||
"id": "kTzwfUPWzrm4", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"from google.colab import files # Para manejar los archivos y, por ejemplo, exportar a su navegador\n", | ||
"import glob # Para manejar los archivos y, por ejemplo, exportar a su navegador\n", | ||
"from google.colab import drive # Montar tu Google drive" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "yQQ8nLiMY6wM", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"##Especificando la versión de TensorFlow\n", | ||
"\n", | ||
"Ejecutando \"importar tensorflow\" importará la versión por defecto (actualmente 2.x). Puedes usar la 1.x ejecutando una celda con la \"versión mágica de tensorflow\" **antes de ejecutar \"importar tensorflow\".\n", | ||
"\n", | ||
"### Si no funciona hacer el pip install\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "1j---G3ZY6wN", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"#!pip install tensorflow==1.14\n", | ||
"%tensorflow_version 1.x" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "S-OIfuWLujbt", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"# Importar Tensorflow" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "OPSus73fumtP", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"import tensorflow as tf\n", | ||
"print(tf.__version__)" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "Z9ZTNKptt8dA", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"# Como funciona TensorFlow" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "IC_M6LlGuAp-", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"1. Importación o generación del conjunto de datos.\n", | ||
"2. Transformación y normalización de los datos.\n", | ||
"3. Dividir el conjunto de datos en conjunto de entrenamiento, de validación y de test.\n", | ||
"4. Definir los hiperparámetros del algoritmo" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "2-V4YdfJsCL5", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"learning_rate = 0.01\n", | ||
"batch_size = 50\n", | ||
"iterations = 10000" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "7v5UxcIMuINd", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"5. Inicializar variables y placeholders" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "AbgaGmAFuen3", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"x = tf.constant(30)\n", | ||
"x_input = tf.placeholder(tf.float32, [None, 3]) #None: no sabemos cuantos vectores introducimos Input_size , vectores de 3 coordenadas\n", | ||
"y_input = tf.placeholder(tf.float32, [None, 5]) " | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "E6fR1pKJuLaZ", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"6. Definir la estructura del modelo del algoritmo.\n", | ||
"$$y = mx+n$$" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "t0sPANbqu909", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"y_pred = tf.add(tf.multiply(m_matrix, x_input), n_vector) #add sumar #multiply multiplicar " | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "1wrcpp_PuSEL", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"7. Declarar la función de pérdidas (loss function)\n", | ||
"$$MSE = \\frac{\\sum_{i=1}^n(y_{actual,i}-y_{pred,i})^2}{n}$$" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "PMRrdFr8vAA4", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"loss = tf.reduce_mean(tf.square(y_actual - y_pred)) #reducir la media de los cuadrados" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "FF8ovbE4uUHB", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"8. Inicializar y entrenar el modelo anterior. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "8sv0a7czvClk", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"with tf.Session(graph = graph) as session:\n", | ||
" ...\n", | ||
" session.run(...)\n", | ||
" ...." | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "wgpFhDMpvEkn", | ||
"colab_type": "code", | ||
"colab": {} | ||
}, | ||
"source": [ | ||
"session = tf.Session(graph = graph)\n", | ||
"...\n", | ||
"session.run(...)\n", | ||
"..." | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "rFYN2Z4yuV79", | ||
"colab_type": "text" | ||
}, | ||
"source": [ | ||
"9. Evaluación del modelo \n", | ||
"10. Ajustar los hiper parámetros\n", | ||
"11. Publicar (subir a producción) y predecir nuevos resultados" | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.