tag:blogger.com,1999:blog-19598028556126186782024-03-14T17:56:22.939+01:00Nicolas BortolottiIngeniería de software, tecnología e innovación aplicados a los nuevos desafíos de desarrollo.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.comBlogger204125tag:blogger.com,1999:blog-1959802855612618678.post-458486943864426382021-02-07T11:06:00.003+01:002021-02-07T11:06:56.425+01:00TensorFlow Lite con Go API en 7 pasosTensorFlow Lite es un marco de aprendizaje profundo de código abierto para la inferencia en el dispositivo. La <a href="https://nickbortolotti.medium.com/tensorflow-lite-using-go-api-in-7-steps-9cab2fe7d0dd">API actual es compatible oficialmente con Python, Java y C ++</a>. La pregunta principal aquí es, ¿qué pasaría si quisiéramos usar Go & TensorFlow Lite?<div><span><br /></span></div><div><span id="docs-internal-guid-c26afc88-7fff-c12d-a413-0b1cab9236f4">El objetivo de este artículo es brindar la oportunidad de usar Go en el poderoso mundo de la inferencia en el dispositivo y también brindar una experiencia de uso fluida.<br /><br />Hay algunas iniciativas trabajando en eso, pero sin un diseño central claro, un entorno de mantenimiento y dependencias.</span></div><div><span><br />Para la propuesta inicial, decidí usar la biblioteca TensorFlow Lite C y para el enlace estoy usando <a href="https://golang.org/cmd/cgo/">cgo</a> (cgo permite la creación de paquetes Go que llaman código C) para implementar la solución.<br /><br />Creé la versión inicial de la biblioteca <a href="https://github.com/nbortolotti/tflitego">tflitego</a>. * Siempre damos la bienvenida a los contribuyentes, expertos y expertos en inferencia en el dispositivo, etc.<br /><br /></span>Aquí el diseño de la versión inicial:<span><br /><div><span style="font-family: Calibri, sans-serif; font-size: 12pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjsqvhDw6vdm1RNW09QiRdKXSs1b-VNrQfp9wbRB4p4D_jKuBGOzDTkxLq7W-OGPIAk7r0cgLd5l2YZpwdHmidWDqpdUr3mBkFUmMHeczc_NcehRWqupqEwVAAnfk2XM6U0RFpAd9wyhuP/s761/tflitego-tflitego_0.0.2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="631" data-original-width="761" height="530" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjsqvhDw6vdm1RNW09QiRdKXSs1b-VNrQfp9wbRB4p4D_jKuBGOzDTkxLq7W-OGPIAk7r0cgLd5l2YZpwdHmidWDqpdUr3mBkFUmMHeczc_NcehRWqupqEwVAAnfk2XM6U0RFpAd9wyhuP/w640-h530/tflitego-tflitego_0.0.2.png" width="640" /></a></div><br />También creé un <a href="https://github.com/nbortolotti/tflitego_examples">proyecto de ejemplos</a> inicial con la propuesta, el objetivo aquí es usar el modelo Iris TensorFlow lite y ver tflitego en acción. Básicamente, necesitamos 7 pasos para ejecutar una inferencia simple.</div><div><span style="font-size: 12pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><span><span style="font-family: inherit;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4sWc0X9Kvn7ip3x20Ob6V0PGU1a5y995f5JB0a2tfDMFCSn0L5GMAT28wMJpe17txL9d5cMQ5PmJRSYTOUO5IjnzJg8B1GJwaNKXI6gk8HS-BPYIqcA4BN8BJDXlKt7cMW-_DRQ24RY0r/s426/iris3.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="240" data-original-width="426" height="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4sWc0X9Kvn7ip3x20Ob6V0PGU1a5y995f5JB0a2tfDMFCSn0L5GMAT28wMJpe17txL9d5cMQ5PmJRSYTOUO5IjnzJg8B1GJwaNKXI6gk8HS-BPYIqcA4BN8BJDXlKt7cMW-_DRQ24RY0r/w640-h0/iris3.gif" width="640" /></a></div></span></span></span></div><div><ol style="text-align: left;"><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Creación de modelos</span></span></li><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Establecer opciones de intérprete</span></span></li><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Crear intérprete</span></span></li><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Asignar tensores</span></span></li><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Tensor de entrada</span></span></li><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Invocación de intérprete</span></span></li><li><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">Salidas / Resultados</span></span></li></ol><span style="font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><span id="docs-internal-guid-001dbe11-7fff-8f1e-bcd8-f8dbc9fddb21">En cuanto al entorno de implementación, creé una representación en acciones de GitHub para probar la simplicidad de uso de tflitego. (linux / X86_64, 2.4.0, Ubuntu 18.04). * TensorFlow 2.4.0. La clave es un paquete para implementar correctamente la biblioteca C de TensorFlow. Ejemplo <a href="https://github.com/nbortolotti/tflitego/actions/runs/459793626/workflow">aquí</a><br /><br />También representé un método de implementación simple para usar en raspberry pi, por ahora probado en v3. Raspberrypi_linux / ARMv7, 2.4.0 * TensorFlow 2.4.0.<br /><br />Mas detalles sobre tflitego: <a href="https://github.com/nbortolotti/tflitego">https://github.com/nbortolotti/tflitego</a><br />Mas detalles sobre los ejemplos utilizando tflitego: <a href="https://github.com/nbortolotti/tflitego_examples">https://github.com/nbortolotti/tflitego_examples</a></span></span></div></span></div>Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-35592838858302515362020-02-16T13:13:00.004+01:002020-02-16T13:13:49.399+01:00Comparación de inferencia en imágenes con host CPU & dispositivo Coral Acelerador & TFlite¿Qué sucedería si preparamos un experimento que comparara un modelo con características similares usando CPU de escritorio tradicional y por otro lado, una EDGE TPU?<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;">Cada Edge TPU es capaz de ejecutar 4 trillones de operations (tera-operaciones) por segundo (TOPS), utilizando 0.5 watts por cada TOPS (2 TOPS por watt). como se traduce este rendimientopara su aplicación dependerá de una variedad de factores. Cada modelro de red neuronal tiene diferentes requerimientos, y si stá utilizando un dispositivo acelerador USB, el rendimeinto total también variará dependiento el CPU host, la velocidad de USB y otros recursos del sistema. <a href="https://coral.ai/docs/edgetpu/benchmarks/">referencia</a> (english)</span></blockquote>
Exploremos ahora una experiencia utilizando el acelerador USB,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqEv3XFnHCcmjzSvb0FoJ5Cy3i6wPE2k9RB7ZS_s9YJwi7uJvolaBzoHi8fZWjCjswG5Zk1jEs0pfRF9x6DQms-Gb1hEhDxemBNIQ6HHgQExaLCrLQwn_tCqd3VaqChmKQsrDWOf-y2xds/s1600/coral_product_accelerator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="657" data-original-width="693" height="377" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqEv3XFnHCcmjzSvb0FoJ5Cy3i6wPE2k9RB7ZS_s9YJwi7uJvolaBzoHi8fZWjCjswG5Zk1jEs0pfRF9x6DQms-Gb1hEhDxemBNIQ6HHgQExaLCrLQwn_tCqd3VaqChmKQsrDWOf-y2xds/s400/coral_product_accelerator.png" width="400" /></a></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiChzLU5b5wHjyyMSkOrxCjYs6xPjjkyoubgySzvKe40KkZ1d-ZncaanyHrcaKOgw9mXPu0PI6Ry_Oo8ZinKL9hp11vXzA6J1VOOGhaBQHEaRLRayp9EBghurus-2uJ_U9TM8q9elD9ZauI/s1600/IMG_20200206_112958.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="1567" data-original-width="1600" height="313" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiChzLU5b5wHjyyMSkOrxCjYs6xPjjkyoubgySzvKe40KkZ1d-ZncaanyHrcaKOgw9mXPu0PI6Ry_Oo8ZinKL9hp11vXzA6J1VOOGhaBQHEaRLRayp9EBghurus-2uJ_U9TM8q9elD9ZauI/s320/IMG_20200206_112958.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">tomando contacto con el dispositivo</td></tr>
</tbody></table>
<h3>
</h3>
<h2>
<br />Comenzando el experimento</h2>
Al explorar la tabla de "tiempo por inferencia", tengo curiosidad por experimentar con la inferencia de modelos, utilizando una CPU de escritorio y con la misma CPU host delegar la inferencia al dispositivo Coral. Entonces, el desafío inicial aquí es explorar las diferencias entre ambos entornos utilizando el experimento más homogéneo posible.<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj31f-ZEibUde9jWh4hTveqa2gqAANo18IoRy5ErPkJDPCjygdNJzHltGAbBRQ8oVVAThrXskUuHpiOorqEN04rJn8kQi7bP47gS1LOAlX7MbbnXH1GCTOJvmu6f0oIrorXODcSOXoTk2SD/s1600/screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="748" data-original-width="807" height="370" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj31f-ZEibUde9jWh4hTveqa2gqAANo18IoRy5ErPkJDPCjygdNJzHltGAbBRQ8oVVAThrXskUuHpiOorqEN04rJn8kQi7bP47gS1LOAlX7MbbnXH1GCTOJvmu6f0oIrorXODcSOXoTk2SD/s400/screenshot.png" width="400" /></a></div>
<div>
<br />
<h2>
La pregunta inicial está relacionada con el método de inferencia</h2>
<blockquote class="tr_bq">
<span style="font-size: x-small;">Edge TPU es compatible solo con los modelos TensorFlow Lite. Por lo tanto, generalmente debemos entrenar un modelo TensorFlow, convertirlo a TensorFlow Lite y compilarlo para Edge TPU. <a href="https://coral.ai/docs/edgetpu/inference/">referencia</a> (english)</span></blockquote>
Para este experimento, seleccionaré un modelo general y el equivalente <b>quantized</b> ... o sea preparado para Edge TPU y una implementación para Python.<br />
<h2>
¿Dónde puedo descargar un modelo?</h2>
Por supuesto, podemos usar TF Hub y explorar diferentes versiones de modelos, también en la <a href="https://coral.ai/models/">página de Coral</a> es posible ver muchos modelos <b>quantized</b>.<br />
<br />
Ahora comencemos el experimento, decidí explorar la arquitectura del modelo MobileNet v2 y 224 como tamaño de imagen.<br />
<br />
Intentaré seguir 2 pasos simples:<br />
<div>
<ul>
<li>Crear una implementación para analizar imagenes utilizando CPU de escritorio.</li>
<li>Crear una implementación para usar el acelerador Edge TPU Coral y analizar imágenes.</li>
</ul>
</div>
Finalmente, debemos comparar los resultados con la tabla inicial propuesta. *señalando que usaremos un host de tipo CPU diferente.<br />
<h2>
Implementación</h2>
Para el escenario inicial, creé un <a href="https://github.com/nbortolotti/tflite-tpu-experiences/tree/master/inference_exploration/cpu">script python</a> simple para explorar la inferencia en CPU de escritorio, también como alternativa, propuse una <a href="https://github.com/nbortolotti/tflite-tpu-experiences/tree/master/inference_exploration/colab">implementación equivalent</a>e en Colab. (solución integrada con TensorFlow Hub para obtener el modelo)<br />
<br />
Para la aplicación Edge TPU, utilicé un acelerador Coral y <a href="https://github.com/nbortolotti/tflite-tpu-experiences/tree/master/inference_exploration/tflite">aquí</a> está la solución creada para hacer las inferencias.* en el repositorio de código, agregué un archivo "* .sh" para completar los requisitos iniciales y simplificar la representación del experimento.<br />
<br />
<div style="text-align: center;">
<a href="https://github.com/nbortolotti/tflite-tpu-experiences/tree/master/inference_exploration">Acceder al proyecto en GitHub</a></div>
<h2>
Conclusiones</h2>
Finalmente, como mencioné, el rendimiento de la inferencia depende del tipo de CPU, USB y rendimiento del host, pero la ejecución en general con Edge TPU es más de 10 veces más rápida.<br />
<br />
Imagenes 224x224 , arquitectura MobileNet v2 con CPU<br />
<br />
<ul>
<li>i7–7500U CPU 2.70GHz × 2</li>
<li>Linux kernel: 5.3.0–28-generic</li>
<li>Promedio en inferencias: 50 Milliseconds</li>
</ul>
<br />
Imagenes 224x224 , arquitectura MobileNet v2 quantized con Coral Edge TPU accelerator.<br />
<br />
<ul>
<li>Promedio en inferencias: 2.6 Milliseconds</li>
</ul>
<br />
Bien!! muy similar a la tabla de rendimiento inicial :). Ahora puedes experimentar a tu gusto, usando la <a href="https://github.com/nbortolotti/tflite-tpu-experiences/tree/master/inference_exploration">versión provista </a>o variando modelos.<br />
<br />
Este es solo un ejemplo simple, pero ... ¿quieres ver más proyectos usando dispositivos Coral? Echa un vistazo a este <a href="https://coral.ai/projects/teachable-sorter/">teachable-sorter</a></div>
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe width="320" height="266" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/ydzJPeeMiMI/0.jpg" src="https://www.youtube.com/embed/ydzJPeeMiMI?feature=player_embedded" frameborder="0" allowfullscreen></iframe></div>
<br /></div>
<a href="https://medium.com/analytics-vidhya/model-inference-comparison-with-tflite-coral-usb-accelerator-device-f639e13d6e49">Articulo original</a> (english)Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-72017701088330128012019-07-25T10:41:00.000+02:002019-07-26T16:05:07.145+02:00Interesado en formar parte de un TensorFlow SIG?<div>
Si estás interesado en contribuir con TensorFlow con un enfoque específico, una interesante opción es crear or formar parte de un SIG. TensorFlow propone la creación de Grupos de interés especial (SIG) para enfocar la colaboración en áreas particulares. </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPtmXOem0WrNTSS_jODi6lRDVz43ksdVgJwYdsUBSTDPnVcDFLokZ0lwZCsSTHRXxMeuhZyXgpYUY_Wmy-E2N9l_6A8tlwY4fUY4aSjvj9IEwRLveWbdKQWKm6azdpWE69Y5mluzDCQxE/s1600/Screenshot+from+2019-07-21+23-20-30.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="785" data-original-width="1600" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPtmXOem0WrNTSS_jODi6lRDVz43ksdVgJwYdsUBSTDPnVcDFLokZ0lwZCsSTHRXxMeuhZyXgpYUY_Wmy-E2N9l_6A8tlwY4fUY4aSjvj9IEwRLveWbdKQWKm6azdpWE69Y5mluzDCQxE/s640/Screenshot+from+2019-07-21+23-20-30.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<h2>
Que es un TensorFlow SIG?</h2>
<div>
Los SIG proponen su trabajo públicamente. El ámbito ideal para un SIG debería alinearse con un dominio bien definido, donde la mayor participación es mediante el enfoque comunitario. Además, debe haber evidencia suficiente de que hay miembros de la comunidad dispuestos a participar y contribuir en caso de que se establezca este grupo de interés. Mas información aquí, <a href="https://www.tensorflow.org/community/sig_playbook">https://www.tensorflow.org/community/sig_playbook</a></div>
<br />
Si tienes interes en participar, tienes una propuesta o idea para esta iniciativa, aquí tienes un canal de comunidad abierto para explorar la propuesta. <a href="https://tensorflowexperiences.nicolasbortolotti.com/main/sig">https://tensorflowexperiences.nicolasbortolotti.com/main/sig</a><br />
<div>
<br /></div>
<div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
Esta obra está bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.<br />
<div>
<br /></div>
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-809737144361645952019-07-17T14:29:00.000+02:002019-07-17T14:29:02.626+02:00Cloud Platform & Comunidades, experiencias de verano en Suiza e ItaliaSemanas atrás con el equipo europeo de comunidades & developers, iniciamos actividades junto a algunas comunidades especializadas en Aprendizaje Automático y Cloud Platform. Además como parte de esta nueva iniciativa, participamos en algunos Meetups & Actividades. Visitamos 2 comunidades, Zurich y Milano presentando la propuesta de <a href="https://go.qwiklabs.com/cloud-study-jams-2019">Cloud Study Jam</a>.<br />
<br />
Inicialmente compartimos una muy linda experiencia junto a <a href="https://www.meetup.com/School-of-AI-Zurich/">SOAI chapter in Zurich</a>. Aquí presentamos los fundamentos de <a href="https://go.qwiklabs.com/cloud-study-jams-2019">Cloud Study Jam</a> y agregamos una sesión práctica sobre CloudML engine.<br />
<br />
Cloud Study Jam Overview:<br />
<iframe allowfullscreen="true" frameborder="0" height="569" mozallowfullscreen="true" src="https://docs.google.com/presentation/d/e/2PACX-1vQdYDpdz8Gsu6zzbZot0OFKzdvbEZL2Ltt-erqEX0HZ2tZx7KTA8pjKODAlg5udzl7pkaXUsT3pkf7k/embed?start=false&loop=false&delayms=3000" webkitallowfullscreen="true" width="960"></iframe>
<br />
* el componente central del formato Cloud Study Jam es la utilización de la plataforma <a href="https://google.qwiklabs.com/">qwiklabs</a> que provee el soporte a los tutoriales y laboratorios online.<br />
<br />
Cloud Study Jam, workshop "Cloud ML Engine: Qwik Start":<br />
<iframe allowfullscreen="true" frameborder="0" height="569" mozallowfullscreen="true" src="https://docs.google.com/presentation/d/e/2PACX-1vTVerlHBdafMXGnre3hDIDitFBlYSgywZC2sGUo7Y7A4IYVFvITaX7X0zfNGBvh5Yzf25v410jsIibr/embed?start=false&loop=false&delayms=3000" webkitallowfullscreen="true" width="960"></iframe>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzbN0pC8N-d6Bf17RJ22rNA42Tr4LgtGNgkl_deScNF0xfVakKZyWFA6tPp10R_YBgI9qupWbQ3ZewyD2Hhti_bqeaMFs3mTR5XccqrnYvwIwd7jjTjhWDseYwq4-l0DTkMMjcZCpezoI/s1600/IMG_20190626_192135.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzbN0pC8N-d6Bf17RJ22rNA42Tr4LgtGNgkl_deScNF0xfVakKZyWFA6tPp10R_YBgI9qupWbQ3ZewyD2Hhti_bqeaMFs3mTR5XccqrnYvwIwd7jjTjhWDseYwq4-l0DTkMMjcZCpezoI/s640/IMG_20190626_192135.jpg" width="640" /></a></div>
<br />
Además de esta actividad, compartimos otra muy linda experience junto a <a href="https://www.meetup.com/Machine-Learning-Milan/">Machine Learning Milan</a>.<br />
Enfoque similar a la actividad anterior, iniciando con una vista general sobre <a href="https://go.qwiklabs.com/cloud-study-jams-2019">Cloud Study Jam</a>, agregando una sesión práctica específica sobre AutoML Vision.<br />
<br />
Cloud Study Jam, workshop "Classify Images of Clouds in the Cloud with AutoML Vision"<br />
<iframe allowfullscreen="true" frameborder="0" height="569" mozallowfullscreen="true" src="https://docs.google.com/presentation/d/e/2PACX-1vR1VMDzNfnWPZiRsyYKTnmjlNBtTnPWNoK9UALLxdgQ77ZI3UUVTXEr1c-JtYzQ7i_Y3FEPaA61bAlh/embed?start=false&loop=false&delayms=3000" webkitallowfullscreen="true" width="960"></iframe>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5V-gVML2F6yesL4w8Zsyl96hoZ3DAGSjM3OiZvs8faDRaKE3oaVQYJzXC8yvJYT6kJROnFkQpxSGgOjMIYAf5cLgOg2TI8gglnzIwjUZxFCSyyV1V7-tm_rMO8qRdNpK0Mx0X-6Fb4Oc/s1600/IMG_20190711_161819.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5V-gVML2F6yesL4w8Zsyl96hoZ3DAGSjM3OiZvs8faDRaKE3oaVQYJzXC8yvJYT6kJROnFkQpxSGgOjMIYAf5cLgOg2TI8gglnzIwjUZxFCSyyV1V7-tm_rMO8qRdNpK0Mx0X-6Fb4Oc/s640/IMG_20190711_161819.jpg" width="640" /></a></div>
<div>
<br /></div>
No dejo de sorprenderme gratamente por el talento de las comunidades de desarrolladores en cada ciudad y país, ahora desde hace unos años en todo el marco Europe. El poder de innovación y el espíritu de aprendizaje siempre presente en cada comunidad que visitamos :)<br />
<br />
<a href="https://nickbortolotti.blogspot.com/2019/07/cloud-platform-communities-summer.html">*version en inglés de esta publicación</a><br />
<br />
<br />
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
Esta obra está bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-7663005485691213912019-05-30T14:50:00.001+02:002019-05-30T14:50:43.898+02:00Pensaste en contribuir con TensorFlow? Si estás familiarizado con el concepto de comunidad de desarrolladores, posiblemente la pregunta te resulte natural. <b>Pensaste en contribuir con TensorFlow? . </b>Entonces veamos que opciones disponibles hay y dónde se puede encontrar más información al respecto...<br />
<br />
Aquí podemos ver claramente el mensaje desde la sección comunidad de TensorFlow:<br />
<a href="https://www.tensorflow.org/community/contribute">https://www.tensorflow.org/community/contribute</a><br />
<br />
Luego de describir los valores de la comunidad en el artículo se pueden observar las opciones para contribuir a TensorFlow como, escribir código, mejorar la documentación, responder preguntas en stackoverflow, participar de las discusiones en el foro, contribuir a los ejemplos propuestos en notebooks, investigar bugs en GitHub, etc...<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibehMJacwg-zB231N7NVOrDFyAcLyGUX6Fp43zCXTaMo8PTQmKoms18qXdH9Tvos_xkUTjJ0acs_HVt2gnZfURKAep0-Naaw427N5_ErwwlSKzg8PvSqmhukN5AXX-L9St8AlpCPV8fkBq/s1600/Captura+de+pantalla+de+2019-05-30+14-39-20.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="610" data-original-width="895" height="435" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibehMJacwg-zB231N7NVOrDFyAcLyGUX6Fp43zCXTaMo8PTQmKoms18qXdH9Tvos_xkUTjJ0acs_HVt2gnZfURKAep0-Naaw427N5_ErwwlSKzg8PvSqmhukN5AXX-L9St8AlpCPV8fkBq/s640/Captura+de+pantalla+de+2019-05-30+14-39-20.png" width="640" /></a></div>
<br />
<br />
Además inmediatamente a esta lista de opciones podrás ver una enumeración de proyectos comunitarios actuales.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjmOakN37EZwAbRFxdW8vVjtAZGg_JjsIfUfHet7oBPBMCiEQVCBxer_d0YzZwKD3UChawCRnIR-PqY-iXDVKStWJyIy9s76qziiu-vijW9JIe8MAAKU7bcWobRERK-CJcXfTQWnbT4TJp/s1600/Captura+de+pantalla+de+2019-05-30+14-39-43.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="610" data-original-width="903" height="432" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjmOakN37EZwAbRFxdW8vVjtAZGg_JjsIfUfHet7oBPBMCiEQVCBxer_d0YzZwKD3UChawCRnIR-PqY-iXDVKStWJyIy9s76qziiu-vijW9JIe8MAAKU7bcWobRERK-CJcXfTQWnbT4TJp/s640/Captura+de+pantalla+de+2019-05-30+14-39-43.png" width="640" /></a></div>
<br />
Múltiples opciones para hacer un mejor ecosistema de desarrolladores...<br />
<br />
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Pensaste en contribuir con TensorFlow? </span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-85139194518143006632019-04-11T12:39:00.001+02:002019-04-11T12:40:59.074+02:00Encuesta Stackoverflow 2019, algunos de los resultados claves <br />
Esta mañana dediqué unos minutos a explorar los principales resultados de la encuesta 2019 en <b>stackoverflow</b>, con unas 90k respuestas, este enfoque siempre entrega indicadores interesantes.<br />
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUNdShn4l0yrMqjt3hWRe7YH0ssnPf8dBIwjubU4ia9L49WrQi8zSOh-aRa5rGuUjsHXymh3RSk1N9N07WpdNQwC8An17XmTkPKCbMehCVtzwRzUazALz9QtHV0V5CbBNsvnPAhc2khZEZ/s1600/Captura+de+pantalla+de+2019-04-11+11-24-54.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="592" data-original-width="701" height="539" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUNdShn4l0yrMqjt3hWRe7YH0ssnPf8dBIwjubU4ia9L49WrQi8zSOh-aRa5rGuUjsHXymh3RSk1N9N07WpdNQwC8An17XmTkPKCbMehCVtzwRzUazALz9QtHV0V5CbBNsvnPAhc2khZEZ/s640/Captura+de+pantalla+de+2019-04-11+11-24-54.png" width="640" /></a></div>
El primero de los resultados no sorprende tanto, <a href="https://www.python.org/">Python</a> como principal lenguaje de programación de más rápido crecimiento, era una tendencia y aquí una buena confirmación de su buen presente, la última parte del resultado es interesante de evaluar, principalmente la presencia de <a href="https://www.rust-lang.org/">Rust</a> como el lenguaje más querido. Me gustaría conocer más del porque de esta preferencia por Rust, desde luego que ya tengo algunas ideas, igualmente algo que me gustaría remarcar es el mensaje del uno de los ingenieros Yelp que al utilizar en producción Rust y nos deja un claro mensaje de sus puntos altos... <b>documentación, herramientas y comunidad.</b><br />
<div>
<br /></div>
"All the documentation, the tooling, the community is great - you have all the tools to succeed in writing Rust code", – Antonio Verardi, Infrastructure Engineer<br />
<div>
<br /></div>
<div>
Luego continuando con los elementos claves, un rápido repaso sobre los <b>ingenieros mejores pagos</b> desde DevOps Specialists, el <b>pesimismo</b> de los desarrolladores en Francia y Alemania y el <b>optimismo</b> de los desarrolladores en China .</div>
<div>
<br /></div>
Finalmente algo que coincido plenamente, y quizás muchos de ustedes también los hagan, <b>stackoverflow</b> <b>ahorra tiempo</b> al momento de resolver problemas de desarrollo, la encuesta habla de de 30 a 90 minutos por semana, quizás más, quizás menos, ese análisis se lo dejo a ustedes.<br />
<div>
<br /></div>
<div>
<a href="https://insights.stackoverflow.com/survey/2019#overview">Aquí</a> la encuesta completa, espero que la disfruten<br />
<div>
<br /></div>
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-48275633856464629802019-03-06T19:33:00.001+01:002019-03-06T19:33:32.525+01:00Utilizando TensorFlow 2 preview, una simple comparación entre el rendimiento CPU vs GPU Utilizando <a href="https://www.tensorflow.org/community/roadmap" target="_blank">tf 2</a> en modo eager , un método mucho más afín a coder/desarrollador, intenté realizar un procedimiento simple para multiplicar matrices y explorar el rendimiento entre la ejecución en CPU y GPU.<br />
Utilizando una multiplicación de 2000x2000 e iterando en 100 steps, tenemos estos valores de comparación en segundos.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxLP75loC313coc2K0U-hyuoSvEPiMh-zRyGT3bVM1eCm7BJwK-_qO0wCmwJFKAEaclBJUL69c-NZ9VNKN9DJu6zWlD_rLJ8tWsfk9TfjtucAktwTfeTJDds0g-2TKX9rooZRgEDkvT7Xd/s1600/cpu_gpu_reduced.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="539" data-original-width="790" height="436" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxLP75loC313coc2K0U-hyuoSvEPiMh-zRyGT3bVM1eCm7BJwK-_qO0wCmwJFKAEaclBJUL69c-NZ9VNKN9DJu6zWlD_rLJ8tWsfk9TfjtucAktwTfeTJDds0g-2TKX9rooZRgEDkvT7Xd/s640/cpu_gpu_reduced.gif" width="640" /></a></div>
<br />
*para la ejecución utilicé una instancia VM provista por Google Cloud, la imagen con soporte GPU, la m21.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDXQr4gfzxauQmmQ1s5j8RU3Wc8xfTCVLcBAqxZeRPaAI7bHY3PJuaPjApcAuo_ICKx-CVeZTPiZgdBFKcx6BwimHmQ_Rq1nK_L8nzPXq7GNA-DlYocPl3wJHgsrb2gtkt3bPeLLZk6JNH/s1600/cpu_gpu.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="359" data-original-width="527" height="434" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDXQr4gfzxauQmmQ1s5j8RU3Wc8xfTCVLcBAqxZeRPaAI7bHY3PJuaPjApcAuo_ICKx-CVeZTPiZgdBFKcx6BwimHmQ_Rq1nK_L8nzPXq7GNA-DlYocPl3wJHgsrb2gtkt3bPeLLZk6JNH/s640/cpu_gpu.gif" width="640" /></a></div>
<br />
La rutina es muy simple, puede ver su implementación <a href="https://github.com/nbortolotti/tensorflow_bluepill">aquí</a> desde este proyecto GitHub. <a href="https://github.com/nbortolotti/tensorflow_bluepill/blob/master/device_check.py">device_check.py</a>Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-30247192121181683072019-01-11T17:38:00.006+01:002019-01-11T17:38:58.919+01:00La simplicidad de Keras desde TensorFlowDesde su lanzamiento <a href="https://www.tensorflow.org/">TensorFlow</a> me cautivó por su poder, funcionalidad y enfoque abierto como librería para calculo numérico avanzado y desde luego para representar, diseñar e implementar modelos de aprendizaje automático. Pero desde la incorporación de <a href="https://keras.io/">Keras</a>, la flexibilidad y simplicidad para la representación de modelos de aprendizaje profundo es maravillosa.<br />
<br />
Desde su definición, Keras es una API de alto nivel para construir y entrenar modelos de aprendizaje profundo. Se utiliza para creación rápida de prototipos, investigación avanzada y por supuesto esto es válido también para producción. Tres ventajas claras nos propone, es <b>fácil de usar, modular, y relativamente fácil de extender</b>.<br />
<div>
<br /></div>
<div>
❗ si buscan un glosario en español una opción que se ve bien es el propuesto por Google en su iniciativa "<a href="https://developers.google.com/machine-learning/glossary/?hl=es-419#top_of_page">Glosario sobre aprendizaje automático</a>"</div>
<div>
<br />
Si les interesa analizar un ejemplo que es un tanto académico pero es interesante para afianzar la mecánica de operaciones de un red neuronal simple con enfoque sencillo pero representando aprendizaje profundo, les recomiendo este artículo, "<a href="https://medium.com/@nickbortolotti/iris-species-categorization-using-tf-keras-tf-data-and-differences-between-eager-mode-on-and-off-9b4693e0b22">Iris species categorization using tf.keras, tf.data and differences between eager mode on and off</a>"<br />
<br />
Derivado de este artículo me gustaría concentrar el foco en la definición del modelo desde Keras. Aquí les dejo un video en donde podrán ver en acción esta tarea:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/GQEONrjdNTU" width="560"></iframe>
</div>
<br />
La representación en Keras en muy intuitiva, en este ejemplo presentado estamos definiendo un <a href="https://www.tensorflow.org/api_docs/python/tf/keras/models/Sequential">modelo secuencial</a> de dos capas, en la primera de ellas permite se propone el ingreso de información en una dimensión de 4 elementos con 16 neuronas operativas y luego una segunda capa con una función de activación <a href="https://www.tensorflow.org/api_docs/python/tf/nn/softmax">Softmax</a> para entregar las categorías requeridas propuestas por el caso de uso de la situación modelada.</div>
<br />
Luego compilamos el modelo, en donde definimos la función objetivo que está alineada a nuestra definición de diseño, con un optimizador por <a href="https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/SGD">descenso del gradiente</a>. Todos estos elementos se pueden personalizar de manera muy sencilla dependiendo el objetivo del modelo profundo que se esté diseñando.<br />
<br />
Les dejo el link a GitHub donde podrán ver, contribuir y desde luego ejecutar esta actividad:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://github.com/nbortolotti/tensorflow-experiences/blob/master/colaboratory/Reduced_experience_Iris_dataset_using_tf_data_%26_tf_keras_%26_tensorflow_central_model_py3.ipynb" target="_blank"><img border="0" data-original-height="72" data-original-width="72" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpwE2lJWeloayQFfAf1L9VYiAV_FI4csUS9JqmgJc7jFbDpCbcM03FrSvgYa3dpXkhyphenhyphenHeZ80Jw9Nzb71eYltEcGHZRz7vVzLUWkmQdnip-lxFq66ysl73pmuzhBuO4frByXh9c-fIcouEZ/s1600/github_icon_1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Espero que disfruten el recorrido por esta experiencia inicial en TensorFlow y Keras.<br />
<div>
<br /></div>
<div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">La simplicidad de Keras desde TensorFlow</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-74495396130462988852018-12-02T23:05:00.002+01:002018-12-02T23:34:01.262+01:00TensorFlow Probability ¿Cuál es la probabilidad de que de 6 pacientes seleccionados al azar, 4 se recuperen?La pregunta es muy simple, y el objetivo de este artículo es simplemente introducir la utilización de <a href="https://www.tensorflow.org/probability/">TensorFlow Probability(TFP)</a>. <br />
<br />
Solo algunas palabras sobre TFP, es una biblioteca Python propuesta en <a href="https://www.tensorflow.org/">TensorFlow</a> para facilitar la combinación de modelos probabilísticos y el aprendizaje profundo en hardware moderno (TPU, GPU). Seguramente si pasas mucho tiempo analizando datos, conviviendo con procesos estadísticos, o investigando diseño y modelos de ML será de gran utilidad en tus tareas diarias. Pueden tener más detalles aquí.<br />
<br />
Para esta experiencia seleccioné un problema teoŕico muy simple, que propone una distribución binomial. Si necesita recordar detalles de la distribución binomial <a href="https://en.wikipedia.org/wiki/Binomial_distribution">aquí</a> pueden rápidamente ver sus detalles.<br />
<blockquote class="tr_bq">
Los registros hospitalarios muestran que de los pacientes que padecen cierta enfermedad, el 75% muere. ¿Cuál es la probabilidad de que de 6 pacientes seleccionados al azar, 4 se recuperen?</blockquote>
<b>Nota:</b> Esto parece preliminarmente una <a href="https://en.wikipedia.org/wiki/Binomial_distribution">distribución binomial</a> porque solo hay 2 resultados (el paciente muere o no).<br />
<br />
<div>
Trataremos de resolver este enunciado mediante esta fórmula:<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="margin-left: 1em; margin-right: 1em;"><br /><img height="85" src="https://lh4.googleusercontent.com/Wp2PQYYqmCqKwHP93HOJwpb74dUkByXgkow7XFdQid1usn9shNzgdd8CGAlg4JKG21SWTObBl1QmXAACWmQlYrOmhvaNGbrim7VgsxZToKGVTzYT8XHhdVTUhSVjbgYfWgkVVeZe" width="320" /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a blob="" colab.research.google.com="" colaboratory="" develop="" ensorflow_probability_hospital.ipynb="" github="" href="https://www.blogger.com/" https:="" nbortolotti="" parent="" style="margin-left: 1em; margin-right: 1em;" target="\" tensorflow-experiences=""></a></div>
<h2>
Como lo podemos modela en TensorFlow utilizando TFP?</h2>
Representar este modelo en TensorFlow mediante TFP es muy simple. <a href="https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/Binomial">Aquí</a> les dejo los detalles de la API.</div>
<div>
<a blob="" colab.research.google.com="" colaboratory="" develop="" ensorflow_probability_hospital.ipynb="" github="" href="https://www.blogger.com/" https:="" nbortolotti="" parent="" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="\" tensorflow-experiences=""></a><br />
Nota: voy a utilizar un notebook en colab para que puedas implementarlo de manera muy simple y modificar los valores para casos de experimentación personal.</div>
<div>
<br /></div>
<div>
<script src="https://gist.github.com/nbortolotti/fe662b7ff7a79ee3a268ec98a629de41.js"></script><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://colab.research.google.com/github/nbortolotti/tensorflow-experiences/blob/develop/colaboratory/TensorFlow_Probability_Hospital.ipynb"><img alt=" " border="0" data-original-height="20" data-original-width="117" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFqIw3vgaLVmUKzLOKcUKa5__u7A4H43IyO4Xqk3IjHDwAaq0-WM1Z9scdopIUzbZXDd037zVaDkGaVpZU5h58hGJ1KsvtNeXlnxIrB98M6fDUc5r5iyqwn7ljGxsh_orBjiADGXDV6QTH/s1600/colab-badge.png" /></a></div>
<h3>
Operaciones extras</h3>
pueden verificar el resultado del tensor resultado, también e necesario convertir el tensor para su representación visual. Para estas tareas he creado algunos segmentos de código de soporte.<br />
<h2>
Visualización</h2>
Para este caso mi idea solo fue mostrar el resultado de las probabilidades por paciente mediante barras. Cada uno puede encontrar más variantes para mostrar los resultados. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ0ewjBjLfcjerr4k83LsUuUbHvd9XL9mYON48VW354LRXNNaT0xQ3hJ7S-MXMOiVCspY9wYYN53IKGtZ7eXVOHYZ5p_kHzwlTc4LxZGU8EJbMTfxs3oT9XdgX_D_clvJOow3IX2L6Zr6_/s1600/hospital_probability_2018-11-28+13-59-55.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="406" data-original-width="608" height="425" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ0ewjBjLfcjerr4k83LsUuUbHvd9XL9mYON48VW354LRXNNaT0xQ3hJ7S-MXMOiVCspY9wYYN53IKGtZ7eXVOHYZ5p_kHzwlTc4LxZGU8EJbMTfxs3oT9XdgX_D_clvJOow3IX2L6Zr6_/s640/hospital_probability_2018-11-28+13-59-55.png" width="640" /></a></div>
<h2>
Conclusiones</h2>
<blockquote class="tr_bq">
La probabilidad de que 4 pacientes se recuperen con las condiciones del modelo es muy baja. 0.03295</blockquote>
En un mundo de probabilidades, herramientas como TFP, con integración transparente al flujo de ML, además de la fácil manera de utiliza el nuevo hardware disponible, ofrecen mejores opciones para los profesionales especialistas en datos.<br />
<br />
Más experiencias utilizando TensorFlow en el siguiente <a href="https://github.com/nbortolotti/tensorflow-experiences">repositorio de Github</a></div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Licencia Creative Commons" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">TensorFlow Probability ¿Cuál es la probabilidad de que de 6 pacientes seleccionados al azar, 4 se recuperen?</span> por <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Nicolas Bortolotti</span> se distribuye bajo una <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-14074565034024387472018-03-06T19:53:00.002+01:002018-03-06T19:55:34.095+01:00¿Cuál es tu color de corbata favorito? Análisis en Tensor FlowSeguramente en reuniones formales, encuentros de etiqueta, e incluso en el mundo de los negocios alguna vez eligieron o criticaron el color de una corbata. Esto también es posible para el mundo de la visión por computador.<br />
<br />
El desafío de hoy será analizar una imagen, extraer sus objetos, identificar clases las corbatas y luego analizar su color dominante. Es un lindo desafío si pensamos a futuro combinar de una manera apropiada nuestra vestimenta.<br />
<br />
Vamos a utilizar Tensor Flow y el modelo de Object Detection. Seguiremos este esquema arquitectónico:<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge365vl2KYAWPLsfuyunHdode36cSm0tTKDYuvoiqxDHE06drMToY-0ZB8luKpjfPEkbIvM-aDWBwVqtD4h6VKzjgha2aP-lnwjbOquYMgdUbeltX-kzbxPPWo3dAHPYJ6IH-SKtaF3poH/s1600/What%25C2%25B4s+your+favorite+tie+color_.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="389" data-original-width="720" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge365vl2KYAWPLsfuyunHdode36cSm0tTKDYuvoiqxDHE06drMToY-0ZB8luKpjfPEkbIvM-aDWBwVqtD4h6VKzjgha2aP-lnwjbOquYMgdUbeltX-kzbxPPWo3dAHPYJ6IH-SKtaF3poH/s640/What%25C2%25B4s+your+favorite+tie+color_.png" width="640" /></a></div>
Vamos a seleccionar algunas imágenes y aplicar nuestra propuesta.<br />
<h3>
Imágenes seleccionadas </h3>
El objetivo fue seleccionar diferentes escenarios con diferentes colores para nuestro conjunto de prueba.<br />
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #252525; font-family: "roboto" , "arial" , sans-serif; font-size: 18px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHa3hczQqCfg8SO0DExsWyWwWc9kebEQfg8tqyUIUqYXIJutKDjTRHM3LT5V_ZD87-qnSd2xH-b7rdb2CRSe29zovi0X9aKxfhoX68WPQqZUyARLTLkvTefrn3W_q18R0zyo-tKvgbiGOK/s1600/Screenshot+from+2018-03-02+18-42-08.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="799" data-original-width="801" height="636" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHa3hczQqCfg8SO0DExsWyWwWc9kebEQfg8tqyUIUqYXIJutKDjTRHM3LT5V_ZD87-qnSd2xH-b7rdb2CRSe29zovi0X9aKxfhoX68WPQqZUyARLTLkvTefrn3W_q18R0zyo-tKvgbiGOK/s640/Screenshot+from+2018-03-02+18-42-08.png" width="640" /></a></div>
<h3>
Soluciones</h3>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #252525; font-family: "roboto" , "arial" , sans-serif; font-size: 18px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdBsQEKVBHUHwbpE7uByuuhhrYwjLyJ6jpOjt3z65HzxaMmBEXrLWZsvmxSRSXeJ_FArTPINJLj0BZD2coZnZROXR7YFcSoaceWZ4u-ucRezFX8-CspucOOQPwk0Oj-BdmF78FDI-P0HPs/s1600/Screenshot+from+2018-03-02+18-45-42.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="632" data-original-width="684" height="590" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdBsQEKVBHUHwbpE7uByuuhhrYwjLyJ6jpOjt3z65HzxaMmBEXrLWZsvmxSRSXeJ_FArTPINJLj0BZD2coZnZROXR7YFcSoaceWZ4u-ucRezFX8-CspucOOQPwk0Oj-BdmF78FDI-P0HPs/s640/Screenshot+from+2018-03-02+18-45-42.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #252525; font-family: "roboto" , "arial" , sans-serif; font-size: 18px;"><br /></span></div>
Soluciones en RGBs:<br />
<ul>
<li>[171,14,12]</li>
<li>[249,55,53]</li>
<li>[ 33,144,216]</li>
<li>[48,88,76]</li>
</ul>
<div>
<h3>
Procedimiento utilizado</h3>
Procesaremos las imágenes con el modelo de detección de objetos de Tensor Flow, luego, utilizando las cajas de detección utilizados para identificar los objetos, cortaremos el objeto que nos interese.</div>
<div>
<script src="https://gist.github.com/nbortolotti/bd3d2c5421e527855ff0d1044f28fd2c.js"></script></div>
<div>
<br /></div>
<b>Nota</b>: utilizaremos esta modificación para buscar solo los objetos de la categoría "corbata" y luego tendremos la opción de colocar el porcentaje de confianza para la detección de categoría del objeto.</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
Ahora enviaremos el arreglo numpy de la caja recortada con el objeto a la rutina de detección de color. Esta rutina extraerá el color dominante.<br />
<div>
<br /></div>
<div>
<script src="https://gist.github.com/nbortolotti/9ee4aa75e5d1419eceaf96a2d8bf0f6c.js"></script></div>
<div>
<br /></div>
Veamos la ejecución de la sesión de Tensor Flow:<br />
<div>
<br /></div>
<div>
<script src="https://gist.github.com/nbortolotti/270bfb2493d87e5dc300667c366503e4.js"></script></div>
<div>
<br /></div>
De esta manera simple, tendremos visibilidad del color dominante de cada objeto extraído.<br />
<div>
<br /></div>
Aquí comparto la experiencia completa en un script de Python desde <a href="https://github.com/nbortolotti/tensorflow-code-experiences/tree/master/tie_dominant_color">Github</a>, también puedes probar este ejemplo haciendo clic en este <a href="https://drive.google.com/file/d/1HrQ3wiGzAAK2eeThDFVXRzh9V00eHp7-/view?usp=sharing">notebook de Colab</a>. Si necesita más información sobre Colab y el modelo de detección de objetos, <a href="https://nbortolotti.blogspot.ch/2018/02/tensorflow-object-detection-en-5-clicks.html">visite este artículo</a>.<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsLkKtTVMJEBYRtDOMcuw6XprUOGXn4WrD0t7eIpKYVkRXgiT5ZJySIPsxGAyPZxWo5zWc2lA5sigVd5yRNG0yO1fxj7Q-kS2Fke4rH37G2F5jSl_RAFqf9ot-OkSQ4K83qcfu9UvzzElz/s1600/dominant_color.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1216" height="378" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsLkKtTVMJEBYRtDOMcuw6XprUOGXn4WrD0t7eIpKYVkRXgiT5ZJySIPsxGAyPZxWo5zWc2lA5sigVd5yRNG0yO1fxj7Q-kS2Fke4rH37G2F5jSl_RAFqf9ot-OkSQ4K83qcfu9UvzzElz/s640/dominant_color.gif" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
articulo original en inglés <a href="https://medium.com/@nickbortolotti/what-is-your-favorite-tie-color-tensorflow-analysis-95c5f7554baa">aquí</a>.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">¿Cuál es tu color de corbata favorito? Análisis en Tensor Flow</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-84015982563710136722018-02-16T15:10:00.005+01:002018-02-16T15:10:59.222+01:00TensorFlow Object Detection en 5 clicks desde ColaboratorySi uno de tus objetivos es realizar algunas pruebas de investigación sobre ciencia de datos, aprendizaje automático o un escenario similar, pero a la vez la idea que tienes es utilizar el menor tiempo posible para configurar el entorno, una muy buena propuesta desde el equipo de Google Research es <a href="https://research.google.com/colaboratory/faq.html">Colaboratory</a>. <br />
<div>
<br /></div>
Para esta oportunidad les preparé la utilización de la API de <a href="https://www.tensorflow.org/">TensorFlow</a> Object Detection en solo 5 clicks. Qué opinan si analizamos los objetos de una imagen con el objetivo de usar una implementación de menos de 60 segundos?<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ8Z00BtGvzkTayqI9gEHZdKXwzPfVv8qsvFV0hJRJRclodSfV72X3zgHVMsBrOoLKQfwWD4eeoKKMDt_4SnddzWWHauL6GNNjgIsquTTS0loARrTx0evhex_fNitpi19reiNjM0Ze5iTZ/s1600/colaboratory_5steps_objects.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="501" data-original-width="960" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ8Z00BtGvzkTayqI9gEHZdKXwzPfVv8qsvFV0hJRJRclodSfV72X3zgHVMsBrOoLKQfwWD4eeoKKMDt_4SnddzWWHauL6GNNjgIsquTTS0loARrTx0evhex_fNitpi19reiNjM0Ze5iTZ/s640/colaboratory_5steps_objects.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ejecución del ejemplo en colaboratory</td></tr>
</tbody></table>
<br />
Seguramente se preguntan, cómo pueden usar esta implementación? La respuesta es muy simple, <i>accediendo <a href="https://drive.google.com/file/d/16QQtlCa4-p4zqxuhJ0U-vOAT5dU0txJV/view?usp=sharing">aquí</a> y utilizando la secuencia de pasos propuestos. Pueden ver los detalles de cada paso a continuación.</i><br />
<h2>
Paso 1</h2>
<div>
Para este paso incluí la descarga del modelo al entorno virtual que propone <a href="https://research.google.com/colaboratory/faq.html">Colaboratory</a>. El resto de librerías como la de <a href="https://www.tensorflow.org/">TensorFlow</a> ya está disponibles al conectar el entorno, con lo cual no es una preocupación para esta implementación.</div>
<h2>
Paso 2</h2>
Ahora vamos a establecer todas las importaciones necesarias para ejecutar el ejemplo de detección de objetos. Preste especial atención a las utilidades de de object detección.<br />
<h2>
Paso 3</h2>
Este paso es muy importante porque podemos cambiar el modelo de detección por otro más preciso, pero también podemos afectar mucho el rendimiento de nuestras futuras funciones de detección. Preste atención a <i>MODEL_NAME</i>.<br />
<br />
Además ejecutamos algunos elementos para utilizar un modelo ya establecido y guardado. Finalmente establecemos una función de conversión para la imagen a un arreglo numpy.<br />
<h2>
Paso 4</h2>
En este segmento de la implementación, establecemos las imágenes de prueba a utilizar. Parte del ejemplo oficial del modelo <a href="https://github.com/tensorflow/models/tree/master/research/object_detection">Object Detection</a>.<br />
<h2>
Paso 5</h2>
Ejecutamos la sesión de <a href="https://www.tensorflow.org/">TensorFlow</a>. Iteramos las imágenes y procedemos a la detección de elementos.<br />
<br />
<b>Nota</b>: idealmente se requiere un Google sign-in para hacer la operación simple y transparente.<br />
<br />
También les dejé algunas ideas para incluir sus propias fotografías y realizar pruebas de detección.<br />
<br />
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">TensorFlow Object Detection en 5 clicks desde Colaboratory</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-27949751874642469252018-01-28T10:54:00.000+01:002018-01-28T10:54:06.376+01:00Una opción de servicio para interactuar con cámaras ArloInteractuar con el sistema <a href="https://www.arlo.com/">Arlo</a> es muy atractivo para quienes adquirieron el hardware y disfrutan de todas las bondades de estos equipos. Que por cierto son muy buenos, flexibles y llenos de buenas propiedades.<br />
<b id="docs-internal-guid-58ed0854-381f-86e8-bd1a-3b6454e7e8fd" style="font-weight: normal;"><br /></b>
Para interactuar con este sistema con una perspectiva de desarrollador, encontré dos proyectos interesantes con base python.<br />
<br />
Python-arlo: <a href="https://github.com/tchellomello/python-arlo">https://github.com/tchellomello/python-arlo</a><br />
Arlo: <a href="https://github.com/jeffreydwalter/arlo">https://github.com/jeffreydwalter/arlo</a><br />
<br />
Ambos proponen diferentes características pero python-arlo tiene una buena documentación y estructura de su API.<br />
<br />
El objetivo para esta integración es dar soporte a solicitudes desde <a href="https://assistant.google.com/">Google Assistant</a>, por este motivo lo integre a un proyecto <a href="https://cloud.google.com/appengine/docs/flexible/">App Engine flex env</a>. Incluí <a href="http://flask.pocoo.org/">flask</a> como framework de interacción y con esto tener la opción de utilizar una interfaz de servicios.<br />
<div>
<br />
Este sería nuestro mapa arquitectónico ideal: </div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij2hUm-KVzp7rtdPxjVsOnIFkgpb4EFievCRv2HzVvYmjcGU9HaGpMGbsD7KD_Sj3jMQEusHQM7mpCAQGjExWCFnmMz-qc7PILCque5MFhyphenhyphenAJddhOwtl7Q51DYx_6sgb42_UOA3d0ncQwB/s1600/arlo_service_tensor_eng.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="503" data-original-width="860" height="372" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij2hUm-KVzp7rtdPxjVsOnIFkgpb4EFievCRv2HzVvYmjcGU9HaGpMGbsD7KD_Sj3jMQEusHQM7mpCAQGjExWCFnmMz-qc7PILCque5MFhyphenhyphenAJddhOwtl7Q51DYx_6sgb42_UOA3d0ncQwB/s640/arlo_service_tensor_eng.gif" width="640" /></a></div>
<br />
<br />
Buscamos continuar con la solicitud iniciada por:<br />
<br />
<br />
Hey Google ….<br />
dónde está mi perro? <span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMHH3Xqs8Odz5jjd8vy7HaqEeiXNB_DlVMqw6d9d_JzruSYJ6I50S306HihnnvT_N5zoi6Llr8JkBMjFxCmeuDODWK9YCHgOHw94Si8hwuon9dS4bynTuaknAHpzokx3tXYLVuEj9bYJqz/s1600/arlo_service_assistant_voice.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="502" data-original-width="282" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMHH3Xqs8Odz5jjd8vy7HaqEeiXNB_DlVMqw6d9d_JzruSYJ6I50S306HihnnvT_N5zoi6Llr8JkBMjFxCmeuDODWK9YCHgOHw94Si8hwuon9dS4bynTuaknAHpzokx3tXYLVuEj9bYJqz/s400/arlo_service_assistant_voice.gif" width="223" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
*Por supuesto que la lógica la tendremos que implementar creando diversos <b><i>intents</i></b> en el <b><i>agente</i></b> desde <a href="https://console.dialogflow.com/">DialogFlow</a>. [puede ver más detalles en este artículo, "<a href="https://nbortolotti.blogspot.ch/2018/01/google-assistant-simpleza-de.html">Google Assistant, simpleza de interacción para llamar a un webhook</a>"]<br />
<span id="docs-internal-guid-58ed0854-3821-fcbf-c40b-27790eb0c23f"><b><br /></b></span>
Veamos un método simple utilizado en el servicio:</div>
<div>
<br /></div>
<div>
<script src="https://gist.github.com/nbortolotti/12fb4c3a3ae7336966808b0884b985ba.js"></script></div>
<div>
<br /></div>
<a href="https://github.com/nbortolotti/ArloCamService">Here</a> [ArloCamService] can see the initial version of the service.<br />
<br />
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Creative Commons License" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Una opción de servicio para interactuar con cámaras Arlo</span> by <a href="https://nbortolotti.blogspot.com/" property="cc:attributionName" rel="cc:attributionURL" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</a> is licensed under a <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Creative Commons Attribution-ShareAlike 4.0 International License</a>.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-91932403164655971492018-01-27T11:13:00.001+01:002018-01-27T11:13:29.860+01:00Google Assistant, simpleza de interacción para llamar a un webhookLa creación de una aplicación utilizando <a href="https://assistant.google.com/">Google Assistant</a> es muy simple y de gran impacto para interactuar con usuarios en diversos entornos y particularmente en hogareños.<br />
<br />
Hey Google <br />
...dónde está mi mascota?<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXMRMTxsqEfSD6vQ-Vyk0qrXn2OoFJIp_IZrbkKvaQkRHMYwUYBjOEtUUAgJcxU13MoV7Mm-jONuktHY5d_nCXXCMkOoJjcTnytNYAhYM5tN1UDYWMl_1A6-L1Kb1YIez_iWyGROIwutnL/s1600/arlo_service_assistant_voice.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="502" data-original-width="282" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXMRMTxsqEfSD6vQ-Vyk0qrXn2OoFJIp_IZrbkKvaQkRHMYwUYBjOEtUUAgJcxU13MoV7Mm-jONuktHY5d_nCXXCMkOoJjcTnytNYAhYM5tN1UDYWMl_1A6-L1Kb1YIez_iWyGROIwutnL/s400/arlo_service_assistant_voice.gif" width="223" /></a></div>
<span style="font-family: inherit;"><br />Si planeamos conectar un sistema de cámaras de seguridad, el desafío de encontrar de forma automatizada mi mascota es más factible, luego les voy a dar más detalles de cómo pienso realizarlo. Por ahora nos vamos a preocupar en trabajar en sobre las solicitudes del asistente.</span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
Para crear un agente e interactuar con <a href="https://assistant.google.com/">Google Assistant</a> vamos a utilizar <a href="https://console.dialogflow.com/">DialogFlow</a>.<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
Veamos los principales elementos a tener en cuenta para crear un agente, y desde este agente llamar a un webhook con alguna funcionalidad. *Parte del objetivo será dejar preparada la lógica de interacción con un sistema de seguridad hogareño<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBS09hhvb7npQSsoWX79nyuoG7hRhqHLWczcaWDBHv0dOtPm7HBu1UPVNggNjeqjglZ8XekIHVVzaqXou4U3wnlw9DGJDtZ0GXUPDKIwfkFF1sF5hT4E9GbehgPTSH4AGvRSc70SnIa6gm/s1600/arlo_system.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="600" data-original-width="1168" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBS09hhvb7npQSsoWX79nyuoG7hRhqHLWczcaWDBHv0dOtPm7HBu1UPVNggNjeqjglZ8XekIHVVzaqXou4U3wnlw9DGJDtZ0GXUPDKIwfkFF1sF5hT4E9GbehgPTSH4AGvRSc70SnIa6gm/s320/arlo_system.png" width="320" /></a></div>
<br />
*<a href="https://www.arlo.com/">Arlo</a> System<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></div>
Desde la consola de <a href="https://console.dialogflow.com/">DialogFlow</a>, crearemos un nuevo agente:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4m_XydmKyXzg3Izp8j4y0jiJc-EMI3XuueAPrBniNhL-6cwqylslX8gxH_20DniQt0a1xo8Zir7RGEUPQ1Fd27ksJnT2YjaE9OKMdVa45AMpwpT6MNT43er9Zfsn4KZlPfv0JnvTNdfkq/s1600/assistant_articulo_cap1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="628" data-original-width="700" height="287" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4m_XydmKyXzg3Izp8j4y0jiJc-EMI3XuueAPrBniNhL-6cwqylslX8gxH_20DniQt0a1xo8Zir7RGEUPQ1Fd27ksJnT2YjaE9OKMdVa45AMpwpT6MNT43er9Zfsn4KZlPfv0JnvTNdfkq/s320/assistant_articulo_cap1.png" width="320" /></a></div>
Podemos personalizar los diferentes idiomas de soporte, para este caso voy a utilizar inglés para facilitar las pruebas del agente. [Se puede incluir español y además ir en profundidad, utilizando la versión es-419 - latin]<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_GlMbmamq2ioAzbycjC84SxM-IsSR2zjSoC3sLrXL9dv8DqMjuMlKdGpASDZBQrwcyE0dqm0IulAhEp3EXS84XtTycq4n2LNdnLnc-h6bFDGGVMnMywRAN5k8MBQSzkoJEq1horxtV-Vd/s1600/assistant_articulo_cap2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="910" data-original-width="1242" height="292" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_GlMbmamq2ioAzbycjC84SxM-IsSR2zjSoC3sLrXL9dv8DqMjuMlKdGpASDZBQrwcyE0dqm0IulAhEp3EXS84XtTycq4n2LNdnLnc-h6bFDGGVMnMywRAN5k8MBQSzkoJEq1horxtV-Vd/s400/assistant_articulo_cap2.png" width="400" /></a></div>
Ahora crearemos un <i><b>intent</b></i> donde representaremos el concepto de <i><b>acción</b></i> a realizar por el agente y las reacciones que tendrá el mismo.<br />
<div>
<br />
Preste especial atención a completar las opciones, que el usuario debería utilizar, para desencadenar acciones en el agente.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-F8z-MzqY6bHmulBJphCpPxSyq2YDFv1wSd9AnlgCA977LA6wesQ1pHdE3DYRWgTwMZ7XkXh4DsCtKgHaX-jhM0wTcZRXc-OcTANpjrFWlFPIZ_sdGJhqNDqzNn__miTHvrEz0kNCGGb9/s1600/assistant_articulo_cap3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="924" data-original-width="1218" height="302" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-F8z-MzqY6bHmulBJphCpPxSyq2YDFv1wSd9AnlgCA977LA6wesQ1pHdE3DYRWgTwMZ7XkXh4DsCtKgHaX-jhM0wTcZRXc-OcTANpjrFWlFPIZ_sdGJhqNDqzNn__miTHvrEz0kNCGGb9/s400/assistant_articulo_cap3.png" width="400" /></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
Esta es la representación json del intent:</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<script src="https://gist.github.com/nbortolotti/5c27b0cf61336226f8ba6c7f225357fa.js"></script>
</div>
<div>
<br /></div>
También les comparto las frases utilizadas para comprender al usuario. ¨User Says¨:<br />
<br />
<script src="https://gist.github.com/nbortolotti/24572d4f3239e6dc696f65a2cc9f454e.js"></script><br />
Luego podemos agregar un nombre a la acción, esto es importante para luego desde la implementación hacer seguimiento y agregar lógica.<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><br /></span></div>
Finalmente una parte importante para estas operaciones, es la interacción con <a href="https://es.wikipedia.org/wiki/Webhook">webhooks</a>. Aquí podemos conectar diferentes servicios. Para este ejemplo, el <a href="https://es.wikipedia.org/wiki/Webhook">webhook</a> manipulará un sistema de cámaras de seguridad siguiendo comandos para hacer más simple y flexible la utilidad de un usuario.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSlceACVKwe9nLPkMfo3UTObQ25QLqOSvDwElwTwCK9-0izPRrYepu2B9DpuyTSJmHret9AdJ_KMSNZIMfdIo5BQ_t7mVvTLSMr1K1dq0obSl6t9NLaPsrvtScExPw-hjflV3Ju4a6LUQt/s1600/assistant_articulo_cap4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="706" data-original-width="720" height="313" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSlceACVKwe9nLPkMfo3UTObQ25QLqOSvDwElwTwCK9-0izPRrYepu2B9DpuyTSJmHret9AdJ_KMSNZIMfdIo5BQ_t7mVvTLSMr1K1dq0obSl6t9NLaPsrvtScExPw-hjflV3Ju4a6LUQt/s320/assistant_articulo_cap4.png" width="320" /></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><span id="docs-internal-guid-9689f7da-33f5-2100-a205-5e279016f02b"></span></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<a href="https://github.com/nbortolotti/ArloCamService">ArloCamService</a> es un proyecto de ejemplo que entrega soporte a un webhook para Google Assistant.<br />
<br />
Nuestro plan completo de arquitectura de implementación:<br />
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ28D4eEXjj0NzuBcJl1937gq2MxTp461cKrqwYQi_rtBx2XPWkvRyQ1wKUzUEHZBi3kBKgh050o9FtJ9TZIbhRRrZ_SKrca3IDw5Bc4kvRIcERv1Wq-OpmR64qzSyCWwXVOu1TmbsxmyL/s1600/arlo_service_tensor_eng.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="503" data-original-width="860" height="372" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ28D4eEXjj0NzuBcJl1937gq2MxTp461cKrqwYQi_rtBx2XPWkvRyQ1wKUzUEHZBi3kBKgh050o9FtJ9TZIbhRRrZ_SKrca3IDw5Bc4kvRIcERv1Wq-OpmR64qzSyCWwXVOu1TmbsxmyL/s640/arlo_service_tensor_eng.gif" width="640" /></a></div>
Las acciones de <a href="https://assistant.google.com/">Google Assistant</a> proponen gran utilidad y simpleza de desarrollo, además proveen una gran opción a los desarrolladores de innovar en el ámbito de interacción con el usuario desde la simpleza del diálogo.<br />
<br /></div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Creative Commons License" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Google Assistant, simpleza de interacción para llamar a un webhook</span> by <a href="https://nbortolotti.blogspot.com/" property="cc:attributionName" rel="cc:attributionURL" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</a> is licensed under a <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Creative Commons Attribution-ShareAlike 4.0 International License</a>.
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-34613389848796117342017-10-12T19:10:00.001+02:002017-10-12T19:10:59.852+02:00Siguiendo a Messi utilizando TensorFlow y Object DetectionEn publicaciones anteriores estuvimos utilizando <a href="https://www.tensorflow.org/">TensorFlow</a> en combinación con el modelo de <a href="https://github.com/tensorflow/models/tree/master/research/object_detection">Object Detection</a>, pero siempre haciendo uso de los tradicionales conjuntos de datos preestablecidos [ejemplo <a href="http://cocodataset.org/#home">COCO database</a>]. En esta oportunidad, nuestro desafío debería llevarnos a otro nivel. Les propongo analizar un segmento de un partido de fútbol e identificar sus jugadores. Al hablar de fútbol, lo primero que me vino a la mente es buscar el talento del astro argentino Lionel Messi. Empecemos nuestro análisis:<br />
<ul>
<li>Entrenemos un modelo personalizado que nos permita ubicar a astro argentino.</li>
<li>Analicemos una transmisión real [en este caso seleccioné Uruguay-Argentina por eliminatorias 31 de agosto 2017] para ver qué resultados podemos obtener.</li>
<li>Pensemos si es posible mejorar o aportar algo a la táctica de este pasional deporte, utilizando esta tecnología.</li>
</ul>
*Vamos a utilizar <a href="https://www.tensorflow.org/">TensorFlow</a> y el modelo propuesto para <a href="https://github.com/tensorflow/models/tree/master/research/object_detection">Object Detection</a>, todo bajo licencia Apache License 2.0.<br />
<div>
<br />
En esta oportunidad voy a empezar por mostrarle el resultado obtenido:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfTLHn85Y4XIOSv4kta-XB6VwLLUjPG6DLGr78erLwjkt9nRrvjmf0FzrjgBufic3dHXj5qR2ZEUcAA6_ZU6h8seFlXW5OO2RbYcV_2MdR9ZKV7FVNxedbRF1SWHpAA8sy9LRFpPTYNry7/s1600/messi_slow_simple.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="238" data-original-width="427" height="355" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfTLHn85Y4XIOSv4kta-XB6VwLLUjPG6DLGr78erLwjkt9nRrvjmf0FzrjgBufic3dHXj5qR2ZEUcAA6_ZU6h8seFlXW5OO2RbYcV_2MdR9ZKV7FVNxedbRF1SWHpAA8sy9LRFpPTYNry7/s640/messi_slow_simple.gif" width="640" /></a></div>
<br />
Si les parece interesante, los invito a dedicar unos minutos más y seguir el paso a paso, para comprender el procedimiento de construcción de este modelo.<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b id="docs-internal-guid-40973d11-106a-0db9-7888-25141543c77d" style="font-weight: normal;"><br /></b></span></div>
Debemos completar dos elementos importantes:<br />
<ol>
<li><b>Construir</b> la base de datos personalizada con los objetos a detectar. [en este caso Lionel Messi en plena acción]. </li>
<li><b>Entrenar y evaluar</b> el modelo utilizando TensorFlow.</li>
<li><b>Utilizar</b> el modelo creado.</li>
</ol>
<h3>
Paso a paso</h3>
<h4>
<span style="vertical-align: baseline;">Momento de construir la base de datos personalizada</span></h4>
<div>
<ol style="margin-bottom: 0pt; margin-top: 0pt;"><span style="vertical-align: baseline;">
<li>Si exploramos la documentación oficial, encontraremos una sección exclusiva para construir nuestro dataset personalizado. <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/using_your_own_dataset.md">Aquí</a> lo pueden ver.</li>
<li>Necesitamos las fotografías de los objetos que queremos detectar y el etiquetado de las mismas.</li>
<ol>
<li>Para este caso como herramient utilicé <a href="https://rectlabel.com/">RectLabel</a>, una buena opción para MacOS. [hay otra alternativas que podrían evaluar como <a href="https://github.com/tzutalin/labelImg">LabelImg</a>]</li>
<li>Luego para las primeras pruebas he recolectado unas 119 fotografías[muy poco cantidad, solo con fines de prueba] de un partido de fútbol. </li>
<li>He etiquetado unas 100 unidades seleccionando al astro Argentino.</li>
</ol>
<li>El siguiente paso, es convertir esas fotografías y etiquetas en archivos con <a href="https://www.tensorflow.org/api_guides/python/python_io#tfrecords_format_details">TFFormat</a>. <a href="https://github.com/nbortolotti/tensorflow-code-experiences/blob/master/custom_model_object_detection/generate_tfrecord.py">Aquí</a> pueden ver el script utilizado [utilicé un paso intermedio convirtiendo el marcado xml a csv para las anotaciones de las fotografías, esto da mucha más flexibilidad para los siguientes paso y si hay que repetir parte de esta actividad <a href="https://github.com/nbortolotti/tensorflow-code-experiences/blob/master/custom_model_object_detection/xml_metadata_csv.py">aquí</a> el script].</li>
<li>Recuerden que lo ideal es construir el conjunto de entrenamiento y el conjunto de evaluación.</li>
</span></ol>
<span style="vertical-align: baseline;">
</span>
<br />
<h4>
<span style="vertical-align: baseline;">Momento de entrenar/evaluar el modelo personalizado </span></h4>
</div>
<div>
<ol style="margin-bottom: 0pt; margin-top: 0pt;"><span style="vertical-align: baseline;">
<li>Con estos archivos completos, pasaremos a entrenar el modelo.</li>
<ol>
<li>Para este paso he utilizado <a href="https://cloud.google.com/ml-engine/">ML Engine</a> ya que no contaba con la infraestructura local para realizar el proceso en 1 hora promedio. [<a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_on_cloud.md">aquí</a> está la descripción oficial del procedimiento]</li>
<ol>
<li>5 workers utilizando standard gpu.</li>
<li>también es muy recomendable asociar <a href="https://www.tensorflow.org/get_started/summaries_and_tensorboard">TensorBoard</a> para visualizar el proceso de entrenamiento y evaluación.</li>
<li>Recuerde que debe utilizar una interacción directa con Google Cloud Storage. Es decir todos los archivos deben estar en este tipo de repositorio para poder interactuar con el motor de entrenamiento.</li>
</ol>
</ol>
<li>Luego de una 21.77 unidades utilizadas, 1 hora 9 mins y unos 20k iteraciones tenemos varios checkpoints y un modelo aceptable.</li>
<li>Utilizando el checkpoint más avanzado, procedemos a convertir el modelo entrenado para inferencia. [<a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/exporting_models.md">aquí</a> pueden ver la documentación oficial]</li>
</span></ol>
<br />
<ol style="margin-bottom: 0pt; margin-top: 0pt;"><span style="vertical-align: baseline;">
</span><span style="vertical-align: baseline;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiT6ju9_OfGCcInUG98w995h39J63BIiP1Kr2-XjDms7KOgZPJ02MZP7vnQHAh5NJtdCIVt7kuX0Bphbg3cVnj-9CJyNF3w8mloWc4FAl9M3F51VFGxsMTJ1WeeVsR4-QkAAFi4wnTSW1A/s1600/messi_article_totalloss.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="941" data-original-width="1600" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiT6ju9_OfGCcInUG98w995h39J63BIiP1Kr2-XjDms7KOgZPJ02MZP7vnQHAh5NJtdCIVt7kuX0Bphbg3cVnj-9CJyNF3w8mloWc4FAl9M3F51VFGxsMTJ1WeeVsR4-QkAAFi4wnTSW1A/s640/messi_article_totalloss.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">totalloss del proceso de entrenamiento</td></tr>
</tbody></table>
<div>
<br /></div>
</span><span style="vertical-align: baseline;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcXv3INgvA8gwnDd6AdmHyOHGdNi6sBp3-mQNonBq1T8yzwn1CYVChifgf18Io2ahYLEbWLDZvwaG5EDHLTXKCPVCgCOi_zk8QDgKorHRkv0CtdUiArtsUYIa7xy45aUP_lQgtnyg7H_La/s1600/messi_article_mlengine.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="626" data-original-width="1182" height="338" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcXv3INgvA8gwnDd6AdmHyOHGdNi6sBp3-mQNonBq1T8yzwn1CYVChifgf18Io2ahYLEbWLDZvwaG5EDHLTXKCPVCgCOi_zk8QDgKorHRkv0CtdUiArtsUYIa7xy45aUP_lQgtnyg7H_La/s640/messi_article_mlengine.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">resumen del job en ML Engine</td></tr>
</tbody></table>
</span></ol>
</div>
<div>
<h4>
Utilizar el modelo personalizado</h4>
<ol>
<li>Terminado este procedimiento vamos a utilizado el modelo desde estas opciones:</li>
<ol>
<li>script que utiliza el modelo y genera un video con el resultado de las detecciones. <a href="https://github.com/nbortolotti/tensorflow-code-experiences/blob/master/custom_model_object_detection/od_video_generator.py">Aquí</a> el ejemplo de implementación.</li>
<li>script que puede evaluar el vídeo en realtime y decodificar las etiquetas para calcular las apariciones del astro argentino. <a href="https://github.com/nbortolotti/tensorflow-code-experiences/blob/master/custom_model_object_detection/od_video_label_detector.py">Aquí</a> el ejemplo de implementación. </li>
</ol>
</ol>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/iDQHmWa6ixk" width="560"></iframe></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Mismo video en slow-motion <a href="https://www.youtube.com/watch?v=ZCUJJN0q-To">aquí</a>.</div>
<br />
Quizás es el inicio de una línea de investigación interesante, tratar de mejorar la táctica deportiva, incorporando más jugadores y validando asociaciones.</div>
<div>
<span style="vertical-align: baseline;"><br />Es real que estamos utilizando solo la transmisión que entrega la TV tradicional, pero qué ocurriría si tuviéramos la opción de camaras con más detalles o una visión completa del campo de juego?. Se podrían calcular las posiciones de todos los jugadores, de hecho probamos que se pueden identificar fácilmente, entonces… podríamos encontrar mejores tácticas basadas en la posición de los jugadores y sus conocidas habilidades?<br /><br />Espero que se hayan divertido con este procedimiento, y esperemos ver cada vez más este tipo de implementaciones en disciplinas deportivas, no solo en el fútbol sino en los demás deportes.</span><br />
<span style="vertical-align: baseline;"><br /></span></div>
</div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Siguiendo a Messi utilizando TensorFlow y Object Detection</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-91356892699148843542017-08-25T05:16:00.000+02:002017-08-25T05:16:12.322+02:00Tensor Flow Object Detection sobre Telegram Bot, mi desayuno, frutas y una conversación interactiva <span id="docs-internal-guid-b78f8453-f98f-bb97-7027-738fc7890e05"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;">En este artículo vamos a explorar un caso, donde combinemos la detección de objetos en imágenes utilizando <a href="https://www.tensorflow.org/">Tensor Flow</a> </span></span>(Object Detection API), y la interacción mediante una arquitectura de bots (Telegram platform).<br />
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span>
<span id="docs-internal-guid-b78f8453-f98f-ee50-8846-ff000951ad59"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;">El desafío es crear un bot que pueda interactuar con imágenes en una conversación, para informar al usuario las frutas que contiene su desayuno. Utilizando esta información se pueden entregar muchas variaciones de análisis en el futuro, por el momento solo una prueba de concepto. </span></span><br />
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span>
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-b78f8453-144b-5c26-722f-406526085c4b"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;">Vamos a proponer una integración de <a href="https://github.com/nbortolotti/TensorPhotoXRay">TensorPhotoXRay</a> (nuestra solución para detección de etiquetas en imágenes, <a href="https://nbortolotti.blogspot.com/2017/08/tensorflow-radiografia-de-imagenes.html">artículo previo</a>)</span><span style="font-family: "arial"; font-size: 13.5pt; vertical-align: baseline;"> </span><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;">para detectar frutas en las imágenes y vamos a crear una integración con un Telegram Bot (proyecto <a href="https://github.com/nbortolotti/appengine-telegram-bot">appengine-telegram-bot</a>).</span></span></span><br />
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpqgO2Jvm1HZqmV9B2oSlYh6Q3u0Uph9ezsT23kOhd5Xm_4EDrLPBc5P9zuCuvRGPa_sEUmsnBl3SKxAaRvsHE4HRqsJgB2L5sE6-aDPxuLJch2A1xNeDDURW_2zALwm-NLXEl3RbHP-wu/s1600/bot+and+object+detection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="433" data-original-width="665" height="260" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpqgO2Jvm1HZqmV9B2oSlYh6Q3u0Uph9ezsT23kOhd5Xm_4EDrLPBc5P9zuCuvRGPa_sEUmsnBl3SKxAaRvsHE4HRqsJgB2L5sE6-aDPxuLJch2A1xNeDDURW_2zALwm-NLXEl3RbHP-wu/s400/bot+and+object+detection.png" width="400" /></a></div>
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-b78f8453-144c-e2be-46cc-e67db14ab10c"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;">Esta es la solución terminada y funcionando:</span></span></span><br />
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9cj7F6HjeVySHwvrGn94ohBblXOE5Eh9LQeuRGMw6Jdvf5ZhOz1vaPV1Ap4yYnHWoD6Pm9GrggcJ_ZsXLni25vp_djjiEKrW_yyKqnZJt1sHlvfYkgvUV7RZmbkrAZsWcXdg3heicFJcu/s1600/telegram_2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="360" data-original-width="548" height="420" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9cj7F6HjeVySHwvrGn94ohBblXOE5Eh9LQeuRGMw6Jdvf5ZhOz1vaPV1Ap4yYnHWoD6Pm9GrggcJ_ZsXLni25vp_djjiEKrW_yyKqnZJt1sHlvfYkgvUV7RZmbkrAZsWcXdg3heicFJcu/s640/telegram_2.gif" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Vamos a describir los elementos básicos para utilizar esta arquitectura.<br />
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<b>Creación del bot en telegram:</b> Usted puede conocer más sobre esta opción en este <a href="https://telegram.org/blog/bot-revolution">link oficial</a>. *Elemento Importante de este paso, obtener el token para interactuar la plataforma de telegram.<br />
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<b>Creación de la solución Telegram Bot</b>: vamos a crear un bot basado en App Engine (proyecto <a href="https://github.com/nbortolotti/appengine-telegram-bot">appengine-telegram-bot</a>). *Este es el método de análisis para los mensajes desde Telegram y la llamada al método de detección de imágenes.<br />
<script src="https://gist.github.com/nbortolotti/30a94162cf4db94d5abb592cc6e32b6c.js"></script><br />
Para esta implementación, nosotros utilizamos 50% de confianza en la detección de etiquetas. <a href="https://github.com/nbortolotti/appengine-telegram-bot">Aquí</a> encontrarás el proyecto completo para desplegar. <br />
<div>
<br /></div>
<b>Desplegar la solución de Telegram Bot</b>: en este ejemplo, la solución está diseñado para <a href="https://cloud.google.com/appengine/docs/python/">Google App Engine traditional environment</a>. Debe prestar especial atención a estos elementos.<br />
<div>
<br />
<ul>
<li><b>Telegram Token</b>: para obtener esta información y para crear el bot en la plataforma de telegram, debe interactuar con <a href="https://telegram.me/botfather">BotFather</a>. <a href="https://core.telegram.org/bots">Aquí</a> tiene todas las instrucciones oficiales. </li>
<li><b>Url de integración con TensorPhotoXRay</b>: una vez desplegada la solución, necesitará la url para realizar el análisis. Recuerde que tiene un nuevo método con este formato:</li>
</ul>
rooturl/<b>photobot</b>/photourl<br />
<ul>
<li><b>rooturl</b>: app engine url</li>
<li><b>photourl</b>: url para analizar la imagen</li>
</ul>
</div>
<div>
<b>Configuración del Hook para Telegram</b>: usted debe desplegar la solución en App Engine. Cuando finalice esta acción, usted tendrá este formato de urls.<br />
<div>
<br /></div>
<div>
rooturl/<b>fruit_analysis</b><br />
<ul>
<li><b>rooturl</b>: app engine url</li>
</ul>
<div>
<b>Desplegar la solución de TensorPhotoXRay</b>: esta actividad la puede realizar siguiendo estas instrucciones. Recuerde que esta solución utiliza <a href="https://cloud.google.com/appengine/docs/flexible/python/">App Engine Flexible Environments</a>.</div>
<div>
*He realizado una modificación sobre el proyecto original para agregar un nuevo método que devuelve solo un arreglo de etiquetas sobre la detección de la imagen.<br />
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-b78f8453-1452-64f2-e27d-de6ab112a050"><span style="font-size: 11pt; vertical-align: baseline;"><span id="docs-internal-guid-b78f8453-1455-a2eb-ec74-55da82b17e52">
</span></span></span></span><span style="text-decoration-color: initial; text-decoration-style: initial;">Este es el método:</span><br />
<span style="text-decoration-color: initial; text-decoration-style: initial;"><script src="https://gist.github.com/nbortolotti/bb89d458f0813241171fb79491e17a12.js"></script></span></div>
<div>
<div style="vertical-align: baseline;">
<b>Último paso, vincular Telegram con nuestro Bot desarrollado </b><br />
Ahora, que empiece la diversión...<br />
<ul style="vertical-align: baseline;">
<li>Para que el bot se enlace con nuestra solución en App Engine, debemos establecer el hook.<br />(solo acceda a el link (rooturl/set_webhook) y valide la configuración, con este mensaje "config ok")</li>
</ul>
rooturl/set_webhook<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><span style="font-size: 11pt; vertical-align: baseline;"><br /></span></span></span><br />
<ul>
<li><b>rooturl</b>: app engine url</li>
</ul>
<div style="vertical-align: baseline;">
Ahora, podemos interactuar con un componente que permite colaborar en nuestras opciones de comida, en un futuro sugerir y aprender de una forma muy flexible.<br />
<br />
Hay varios elementos para evolucionar y mejorar, pero esta simple solución muestra un interesante camino lleno de nuevas oportunidades en la interacción con usuarios.<br />
<br /></div>
<div style="background-color: transparent; font-size: 11pt; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; text-decoration-line: none; white-space: pre-wrap;">
</div>
</div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Tensor Flow Object Detection sobre Telegram Bot, mi desayuno, frutas y una conversación interactiva </span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
</div>
</div>
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-1768610742039809512017-08-05T19:58:00.003+02:002017-08-05T19:58:25.475+02:00TensorFlow radiografía de imágenes utilizando Object Detection con App Engine En artículos anteriores analizamos objetos en imágenes utilizando <a href="https://github.com/tensorflow/models/tree/master/object_detection">Tensor Flow Object Detection API</a> aplicando diferentes tipos de modelos (<a href="https://nbortolotti.blogspot.ch/2017/07/tensor-flow-object-detection-en-videos.html">TensorFlow Object Detection en videos, basta de pizza, donuts y cakes...</a>, <a href="https://nbortolotti.blogspot.ch/2017/07/tensorflow-object-detection-api-cena.html">TensorFlow Object Detection API, cena con amigos</a>). En estos ejemplos, la solución siempre estuvo diseñada para una aplicación de consola (es decir un Python script ejecutado localmente).<br />
<br />
Ahora nuestro desafío es llevarlo a un entorno web, detectar objetos dentro de la foto (como una radiografía) y finalmente deberíamos proponer una arquitectura simple de implementación.<h3>
Vista General</h3>
Podríamos pensar varias opciones de arquitectura en donde se utilice un esquema servidor (ejemplo desde la documentación oficial <a href="https://tensorflow.github.io/serving/">TensorFlow Serving</a>). Incluso podríamos pensar en alternativas tradicionales(<a href="https://www.apache.org/">Apache</a>, <a href="https://nginx.org/en/">Nginx</a>, etc) pero debemos pensar en montar el servidor Web y ajustar todos los elementos para realizar el análisis utilizando <a href="https://www.tensorflow.org/">TensorFlow</a>.<br />
<br />
Me gustó mucho la idea de utilizar un esquema de plataforma como App Engine, pero para nuestra propuesta, el entorno tradicional de App Engine tiene varios desafíos (deberíamos incluir elementos como PubSub y workers en VMs, esto introduce algunos grados de complejidad que preferimos evitar), entonces para resolver nuestro desafío utilizaré App Engine Flexible Environment.<br />
<h2>
Solución propuesta</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3_HeQUp9Aty0HcR_JlCNeXMwPbFUZ40z1BXV7nk2KhQ5iDAG3gwWhDfwq66yFY4vjl3nlsyZ5g9BeawqDqx1hgMfqHgpZfkLBKnjTTa16R0tXspk-ElVL2tNoHSdREET5TH4c9vYqPy1U/s1600/object_detection_app_engine_2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="540" data-original-width="687" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3_HeQUp9Aty0HcR_JlCNeXMwPbFUZ40z1BXV7nk2KhQ5iDAG3gwWhDfwq66yFY4vjl3nlsyZ5g9BeawqDqx1hgMfqHgpZfkLBKnjTTa16R0tXspk-ElVL2tNoHSdREET5TH4c9vYqPy1U/s400/object_detection_app_engine_2.gif" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h2>
Arquitectura propuesta</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMRPdXGo1bJ16k9XxKULmXeL610uN_UFbC8UiB3rSjrqcbdAn43ZVPUbZadpawqor8lpY4V813DuZhHju5rIKEVTP7Yjp2_hf7Zmv-naxxbHqi504M8TycuO0SW-vijqJzwjnvO1IKW3_M/s1600/Picture+Tensorflow+and+App+Engine+%25281%2529.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="313" data-original-width="584" height="342" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMRPdXGo1bJ16k9XxKULmXeL610uN_UFbC8UiB3rSjrqcbdAn43ZVPUbZadpawqor8lpY4V813DuZhHju5rIKEVTP7Yjp2_hf7Zmv-naxxbHqi504M8TycuO0SW-vijqJzwjnvO1IKW3_M/s640/Picture+Tensorflow+and+App+Engine+%25281%2529.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<h2>
Proyecto App Engine Flexible Environment</h2>
<ul>
<li>app.yaml</li>
<li>main.py</li>
<li>templates/index.html</li>
</ul>
Más detalles sobre <a href="https://cloud.google.com/appengine/docs/flexible/">App Engine Flexible Environment</a><br />
<br />
<h3>
Rutina de evaluación de imágenes</h3>
<div>
<script src="https://gist.github.com/nbortolotti/96e490871b1cfe96a1856c937a55bd4f.js"></script></div>
<div>
<br /></div>
<div>
<span id="docs-internal-guid-27b4c8a4-aecb-55f0-8121-6dc8c521f7de">*Principales dependencias <a href="http://flask.pocoo.org/">Flask</a>, <a href="https://www.tensorflow.org/">TensorFlow</a> además estos elementos de soporte, <b>numpy, Image, cStringIO, urllib.</b></span></div>
<br />
Tener en cuenta los elementos mínimos necesarios para ejecutar el análisis utilizando <a href="https://github.com/tensorflow/models/tree/master/object_detection">TensorFlow Objects Detection API</a> son los siguientes.<br />
<ul>
<li><b>models [folder]</b></li>
<li><b>proto [folder]</b></li>
<li><b>utils [folder]</b></li>
</ul>
<div>
*si lo desean este <a href="https://storage.googleapis.com/appengine_tensorflow/object_detection_api.zip">archivo</a> tiene todo lo necesario de este ítem.</div>
<div>
<b><br /></b></div>
<div>
<span id="docs-internal-guid-27b4c8a4-aecc-3261-5559-0248d7330dcd">Además necesitamos tener el <b>frozen_inference_graph</b> del modelo en nuestra solución. Para nuestro ejemplo:</span><br />
<ul><span id="docs-internal-guid-27b4c8a4-aecc-3261-5559-0248d7330dcd">
</span>
<li><b>ssd_mobilenet_v1_coco_11_06_2017 </b>(para más precisión en la detección se puede variar el modelo)</li>
</ul>
<div>
*si lo desean este <a href="https://storage.googleapis.com/appengine_tensorflow/ssd_mobilenet_v1_coco_11_06_2017.zip">archivo</a> tiene todo lo necesario de este ítem.</div>
<div>
<br /></div>
<span id="docs-internal-guid-27b4c8a4-aecc-3261-5559-0248d7330dcd">
</span></div>
<div>
Cómo utilizamos <a href="http://mscoco.org/">COCO</a> como esquema de reconocimiento de objetos, necesitamos la etiquetas de reconocimiento para nuestro análisis.<br />
<ul>
<li><b>mscoco_label_map.pbtxt</b></li>
</ul>
<div>
*si lo desean este <a href="https://storage.googleapis.com/appengine_tensorflow/data.zip">archivo</a> tiene todo lo necesario de este ítem.</div>
</div>
<div>
<br /></div>
Aquí les dejo la implementación en su fase inicial desde este repositorio <a href="https://github.com/nbortolotti/TensorPhotoXRay">Github</a>.<br />
<h2>
Despliegue de la solución</h2>
Nota: recuerden que deben contar con el Google Cloud SDK. <br />
<br />
<b>Local</b>:<br />
<ul>
<li>python main.py </li>
</ul>
<br />
<b>Ambiente producción:</b><br />
<ul>
<li>gcloud app deploy </li>
</ul>
* [-v versión] si quiere desplegar en una versión específica.<br /><div>
<br /></div>
<div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">TensorFlow radiografía de imágenes utilizando Object Detection con App Engine </span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-61255866978737780622017-07-23T21:37:00.002+02:002017-07-23T22:12:03.068+02:00Tensorflow Object Detection, una mirada a las publicaciones en FacebookEn historias anteriores detectamos algunos <a href="https://nbortolotti.blogspot.ch/2017/07/tensorflow-object-detection-api-cena.html">objetos dentro de una imagen</a>, luego hicimos una extensión para <a href="https://nbortolotti.blogspot.ch/2017/07/tensor-flow-object-detection-en-videos.html">analizar un video</a>, de forma muy rudimentaria, pero funcional y hoy tenemos otro desafío. ¿Podemos conocer algo del enfoque social utilizando las imágenes compartidas en alguna de las redes sociales disponibles?. ¿Podríamos realizar esta operación explorando el stream social?<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span>
<br />
<br />
Vamos a asumir que no analizamos contexto real de la situación, solo vamos a concentrarnos en las imágenes de publicaciones compartidas, igualmente este esquema sirve para iniciar el análisis sobre el marco social. Vamos a utilizar un enlace a Facebook para nuestra solución.<span id="docs-internal-guid-efba64ab-70ef-c4a1-3816-0fe51d3ed9cf"><br /></span>
<br />
<br />
Diagrama general de operaciones:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVt6OnXFIg5cxC5Gy8-I_Z6BKG-8X5mNaBL8XkEcmTpXJ5zgDvkvNN5I9ivK6eq9CaKfS2gEPOUZ_KopGJfoTYRSQ8Zs551VdlhytJdq_YeM3TeVLalhsT_jlzZuHbv_nsc_Jp-qBbI9zT/s1600/TensorFlow+Object+Detection%252C+una+mirada+a+facebook+posts.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="232" data-original-width="468" height="315" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVt6OnXFIg5cxC5Gy8-I_Z6BKG-8X5mNaBL8XkEcmTpXJ5zgDvkvNN5I9ivK6eq9CaKfS2gEPOUZ_KopGJfoTYRSQ8Zs551VdlhytJdq_YeM3TeVLalhsT_jlzZuHbv_nsc_Jp-qBbI9zT/s640/TensorFlow+Object+Detection%252C+una+mirada+a+facebook+posts.png" width="640" /></a></div>
Operaciones a realizar:<br />
<ol>
<li>Enlace a un usuario social </li>
<li>Lectura y exploración de cada publicación. </li>
<li>Extracción de la imagen </li>
<li>Análisis de la imagen </li>
<li>Agrupación de las etiquetas detectadas.</li>
</ol>
Veamos la implementación propuesta, análisis sobre mi propio perfil. Exploración de 40 post de las últimas semanas sobre mi perfil.<br />
<div>
<br />
<b>Log de salida siguiendo las operaciones propuestas:</b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtvU0bN-qRhCghxcCRTmGWYBYmI2bdYY37pC-lGVaFuyoVgc0PhGMAf61NiQky4jUr7rirmKalJjMF8M5sz7XXZoyJBhjHUkTNwkTFVKduGZYdCSlAvth9inrMpkOl-KERX5HHXOARWpSJ/s1600/object_detection_log_social.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="894" data-original-width="1600" height="355" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtvU0bN-qRhCghxcCRTmGWYBYmI2bdYY37pC-lGVaFuyoVgc0PhGMAf61NiQky4jUr7rirmKalJjMF8M5sz7XXZoyJBhjHUkTNwkTFVKduGZYdCSlAvth9inrMpkOl-KERX5HHXOARWpSJ/s640/object_detection_log_social.png" width="640" /></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
Información modelada en columnas con una línea de tiempo sobre las publicaciones:</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvuExJMB72Kq00EoM1mvJDiqcjZ16p9usVQWC4K6c7x0HUl32-pZk7yd-BAEq1Fwf9JqkwnM74Ras9VyLyyEy-P943DnXcSPKTRtqu7qT1ptGJku8hvlWnREG5r39-lEt70QwFCGK0K-W/s1600/object_detection_social_dashboard.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="996" data-original-width="1600" height="398" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvuExJMB72Kq00EoM1mvJDiqcjZ16p9usVQWC4K6c7x0HUl32-pZk7yd-BAEq1Fwf9JqkwnM74Ras9VyLyyEy-P943DnXcSPKTRtqu7qT1ptGJku8hvlWnREG5r39-lEt70QwFCGK0K-W/s640/object_detection_social_dashboard.png" width="640" /></a></div>
<b>Nota</b>: he agrupado algunos conceptos frutas, comidas, automotor, personas y snack. Línea de contenidos compartidos desde las imágenes asociadas a cada post.</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
Vamos a utilizar una publicación del 19/06/2016, donde disfrutamos una tarde de snack en familia.</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br />
Publicación social:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB9nKySw9L-cjpAvtTYoEQ02cQH-rOZ_-oD57knoOoEFKXuJCg7zX95-Qqi10GQ7RYYSMYeJXW3ksWh4KgYA04WxeC-Zmzm3GA9WaOfe-z7yXRsOlBoQ_qbDABXlxE8OlIB4BjbLRNbitL/s1600/object_detection_social_post.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1126" data-original-width="1072" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB9nKySw9L-cjpAvtTYoEQ02cQH-rOZ_-oD57knoOoEFKXuJCg7zX95-Qqi10GQ7RYYSMYeJXW3ksWh4KgYA04WxeC-Zmzm3GA9WaOfe-z7yXRsOlBoQ_qbDABXlxE8OlIB4BjbLRNbitL/s400/object_detection_social_post.png" width="380" /></a></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
Análisis de imagen visual:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCVFmVnbMTJshUZFcZoGobaYUZpDRBPobkWvVo1ZgSeiXhcBeED4C9PQUn2iB6q2MuKFBF6kNzFujKw6-p_xMTfc1ykZsULDoQbh9XVIK8zELg6fkrwDzGmhQpxyd78_2gQgsenBWpE-qF/s1600/object_detection_social_post_analysis.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="954" data-original-width="1072" height="355" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCVFmVnbMTJshUZFcZoGobaYUZpDRBPobkWvVo1ZgSeiXhcBeED4C9PQUn2iB6q2MuKFBF6kNzFujKw6-p_xMTfc1ykZsULDoQbh9XVIK8zELg6fkrwDzGmhQpxyd78_2gQgsenBWpE-qF/s400/object_detection_social_post_analysis.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Arreglo de conceptos detectados y su valor de confianza: [{u’cup': 99}, {u'cup': 99}, {u'person': 86}, {u'person': 77}, {u'wine glass': 76}, {u'dining table': 69}, {u'chair': 56}, {u'potted plant': 53}]<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b style="font-weight: normal;"><br /></b></span>
<br />
<b><br /></b>
<b>Conclusiones obtenidas:</b><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b style="font-weight: normal;"><br /></b></span>
<br />
Hay mucho por mejorar en este campo, el contexto de la información recibida, el filtro por publicaciones personales o compartidas, la agrupación por elementos más representativos y muchas variaciones más. Pero para resolver nuestro desafío fue una buena propuesta, tenemos una visión general de análisis social.(Facebook en este caso pero podríamos incorporar otras redes dependiendo la cantidad de información social deseada)<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b style="font-weight: normal;"><br /></b></span>
<br />
<b><br /></b>
<b>Implementación:</b><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span>
<br />
La rutina recibe, el usuario a examinar, la cantidad de posts, y el token para usar la Graph API (Facebook). Aquí la implementación:</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<script src="https://gist.github.com/nbortolotti/99f32ca8d8c08b359a8bef73f04fd2f7.js"></script><br />
Tecnología utilizada:<br />
<ul>
<li><a href="https://www.tensorflow.org/">Tensorflow 1.2.1</a> (object detection api)</li>
<li><a href="http://mscoco.org/">COCO</a> model, faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017</li>
<li><a href="https://github.com/mobolic/facebook-sdk">Python Facebook-sdk</a></li>
</ul>
Una pregunta final aún abierta, podríamos mejorar el ambiente y empatía en encuentros personales conociendo la información social de las personas? <br />
<br /></div>
</div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Tensorflow Object Detection, una mirada las publicaciones en Facebook</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-77975194129967733822017-07-14T21:20:00.002+02:002017-07-14T21:33:38.620+02:00Tensorflow Object Detection en videos, basta de pizza, donuts y cakes...En un <a href="https://nbortolotti.blogspot.ch/2017/07/tensorflow-object-detection-api-cena.html">artículo anterior</a> les compartí un desafío en donde analizamos una imagen de una situación social, una cena con amigos. Ahora vamos a trabajar en un desafío mayor, vamos a analizar videos. En este desafío solo buscaremos detectar un objeto prohibido dentro del video (pizzas, donuts, cakes). Vamos a utilizar una simple metodología:<br />
<ol>
<li>Leemos el video y los separamos por frames (luego los tratamos como imágenes)</li>
<li>Analizamos cada imagen con nuestra rutina de detección de objetos basada en Tensor Flow[version 1.2.1] Object Detection API .</li>
<li>Podríamos volver a ensamblar el video para visualizar los resultados. [tenemos que saber que es un procedimiento que consume muchos recursos]</li>
<li>Como no deseamos ver los resultados de manera visual, les voy a proponer algo. Ya que solo necesitamos identificar un objeto con una probabilidad alta, vamos a colocar reglas para generar una alerta al detectar estas etiquetas dentro del video.</li>
</ol>
El procedimiento de detección y alerta sería el siguiente, cuando encontramos una etiqueta de objeto prohibido con una probabilidad alta, alertamos y cerramos el análisis (hace mucho más veloz el análisis para muchos casos).<br />
<br />
Para la manipulación del video vamos a utilizar, <a href="https://opencv-python-tutroals.readthedocs.io/">OpenCv</a>, si quisiéramos realizar otras operaciones con el vídeo podríamos utilizar también <a href="http://zulko.github.io/moviepy/">moviepy</a>. [entorno python]<br />
<br />
Vamos a concentrarnos solamente en buscar etiquetas con un probabilidad mayor al 50% 60% 90%, si encontramos ese caso, para simplificar el desafío cerraremos la rutina de detección. (también podemos analizar si una etiqueta de las que denominamos prohibidas, está en el mismo momento de una etiqueta persona)<br />
<br />
Veamos los 3 casos propuestos de forma práctica:<br />
<h4>
Caso de donuts </h4>
*Vamos a detallar este primer caso<br />
Extracto video ensamblado con detección visual:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLtBXE_9cUmYjDKp4fwYvsyVg1yYIP4IdG2IaBaNF008FaVynNwCYtvWQKpkFP-1HmthdppvYlvoySpfB-AhvSvy-kKGMIn1_b-cEvJqBwK-tF5xAI-gdND_RVk0Id6HZEhAyjWfLNRW-e/s1600/object_detection_donut_grafico.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="406" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLtBXE_9cUmYjDKp4fwYvsyVg1yYIP4IdG2IaBaNF008FaVynNwCYtvWQKpkFP-1HmthdppvYlvoySpfB-AhvSvy-kKGMIn1_b-cEvJqBwK-tF5xAI-gdND_RVk0Id6HZEhAyjWfLNRW-e/s640/object_detection_donut_grafico.gif" width="640" /></a></div>
<div>
<br />
Animación de la rutina de detección y alerta:</div>
<div>
*Regla para detener la detección con donut > 87%.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYxEK6xObvQPRLOtZRvif2Ncs7ZoC7byLiqrsTtAZzTqqpN0WyFHV8fnSDDCCXcMPgwWmUMFbKY7FgNx8fXWWuubawIAXd2T-YaJLKcpymj-otGGig9-UUrSuKNCz-bPOWhiCeCy_Yasu6/s1600/object_detection_donut.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="480" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYxEK6xObvQPRLOtZRvif2Ncs7ZoC7byLiqrsTtAZzTqqpN0WyFHV8fnSDDCCXcMPgwWmUMFbKY7FgNx8fXWWuubawIAXd2T-YaJLKcpymj-otGGig9-UUrSuKNCz-bPOWhiCeCy_Yasu6/s640/object_detection_donut.gif" width="640" /></a></div>
<div>
<h4>
Caso pizzas</h4>
Extracto video ensamblado con detección visual:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTyRLs8zZXljqLbokqm4H0Pboo0qbBTJnOP8nyjP3Z0arKYva1PYwECUrsWauJPLrPGBY-lP0FAdf9VLrxZutje7pM6Ee5Xgc0K4I0U4xr_nTc32uf9nM2AuJg3-5hPB6jE3KxgaEP8aqe/s1600/object_detection_pizza_grafico.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="406" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTyRLs8zZXljqLbokqm4H0Pboo0qbBTJnOP8nyjP3Z0arKYva1PYwECUrsWauJPLrPGBY-lP0FAdf9VLrxZutje7pM6Ee5Xgc0K4I0U4xr_nTc32uf9nM2AuJg3-5hPB6jE3KxgaEP8aqe/s640/object_detection_pizza_grafico.gif" width="640" /></a></div>
<div>
<br />
Muchas veces, como este caso, la identificación visual es muy pequeña, pero nuestra rutina no tiene problemas con eso.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaQoGDXMmrpll-v745arrGjmwam64aDlJx9n_4DjhAwVnke2IsbrhImvUDeBqheX965BKgYAk3QXuBd4lKMJpXXZI2BIkFIQ3_Bg5ZhFBNKH_3j-e5PPea5Ft8mnlxCyRAON7pakvfCnqz/s1600/object_detection_pizza.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="918" data-original-width="1600" height="364" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaQoGDXMmrpll-v745arrGjmwam64aDlJx9n_4DjhAwVnke2IsbrhImvUDeBqheX965BKgYAk3QXuBd4lKMJpXXZI2BIkFIQ3_Bg5ZhFBNKH_3j-e5PPea5Ft8mnlxCyRAON7pakvfCnqz/s640/object_detection_pizza.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<h4>
Caso Cakes</h4>
Extracto video ensamblado con detección visual:<br />
<br />
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVe14Sev_n2Y-han0U6t9nVQBoktuT6LIKZMxHfQsOEJWfQ6fBI8X70zIP1E6E2OtaJg3i6RW3B5LrAZvKMTJqMxvQLQGykqA7-EHAawZYTsfKt4DyHbrZ-Jft8W6CXJPfxi0cEdadKSl/s1600/object_detection_cake_grafico.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="406" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVe14Sev_n2Y-han0U6t9nVQBoktuT6LIKZMxHfQsOEJWfQ6fBI8X70zIP1E6E2OtaJg3i6RW3B5LrAZvKMTJqMxvQLQGykqA7-EHAawZYTsfKt4DyHbrZ-Jft8W6CXJPfxi0cEdadKSl/s640/object_detection_cake_grafico.gif" width="640" /></a>
</div>
<br />
Ahora si sus pareja les prohíbe ingerir estos alimentos, tendrán que tener más cuidado, o por lo menos evitar tener un video del mismo.<br />
<br />
Aquí la rutina completa:<br />
<br /></div>
<script src="https://gist.github.com/nbortolotti/99e1ad329383de04be4834a8c3e28c0d.js"></script>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Tensorflow Object Detection en videos, basta de pizza, donuts and cakes...</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-64154521170500781332017-07-05T12:19:00.000+02:002017-07-05T12:19:00.023+02:00TensorFlow Object Detection API, cena con amigosDía a día se registran avances en gran cantidad de sectores aplicando inteligencia artificial, y desde luego no es la excepción el sector de aprendizaje en visión automatizada. Hace unos días, el equipo de Google Research publicó un <a href="https://research.googleblog.com/2017/06/supercharge-your-computer-vision-models.html">artículo</a> con la propuesta de #Tensorflow API para detección de objetos. Por este motivo, me gustaría dejar un desafío. Podríamos detectar de forma automática los elementos en una cena con amigos?<br />
<br />
Para este objetivo lo ideal sería utilizar un modelo pre entrenado, tenemos algunas opciones listas para utilizar :<br />
<ul>
<li>ssd_mobilenet_v1_coco_11_06_2017</li>
<li>ssd_inception_v2_coco_11_06_2017</li>
<li>rfcn_resnet101_coco_11_06_2017</li>
<li>faster_rcnn_resnet101_coco_11_06_2017</li>
<li>faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017</li>
</ul>
<div>
Todos los modelos utilizan COCO, (common objects in context) puedes ver los detalles <a href="http://mscoco.org/home/">aquí</a>.</div>
<div>
<br /></div>
Veamos nuestra imagen original, que hipotéticamente se acaba de capturar por uno de los participantes de la cena:<br />
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmrThD3E6pEaHlussANpCgGIJddOe2sFI5Lcl_l8J45xLCaseF6ivX9scFNwU4R2ixlxZaBSuWU3g1ztnCWY3L79Tr0Fx9605ajzrvHfzmA0EIxMk3DKjUedNM2doa2PZs2SaO-HKSNFVi/s1600/image2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="375" data-original-width="500" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmrThD3E6pEaHlussANpCgGIJddOe2sFI5Lcl_l8J45xLCaseF6ivX9scFNwU4R2ixlxZaBSuWU3g1ztnCWY3L79Tr0Fx9605ajzrvHfzmA0EIxMk3DKjUedNM2doa2PZs2SaO-HKSNFVi/s640/image2.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Image reference COCO database</td></tr>
</tbody></table>
Y veamos nuestro rápido procesamiento con #TensorFlow, para este análisis, la mejor respuesta que obtuve fué utilizando <b>faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017</b>. [<a href="https://arxiv.org/abs/1506.01497">faster_rcnn</a> y <a href="https://arxiv.org/abs/1602.07261">inception_resnet</a>]<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKqgvaQ6oDlDcIP81Xp1J-dE-Pq9BY2igUSQVOrOV2MkrZQb_MvRLJQDzNhKTByK5euGnZk2cwiGv3z2fd1Xp0md7yyKO_bK_nSLsLDLfFa9VNqmB2Zpy-rREhiTsIP5wBP1cc-ZoA3Y5j/s1600/coco_model_detection_4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1197" data-original-width="1600" height="478" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKqgvaQ6oDlDcIP81Xp1J-dE-Pq9BY2igUSQVOrOV2MkrZQb_MvRLJQDzNhKTByK5euGnZk2cwiGv3z2fd1Xp0md7yyKO_bK_nSLsLDLfFa9VNqmB2Zpy-rREhiTsIP5wBP1cc-ZoA3Y5j/s640/coco_model_detection_4.png" width="640" /></a></div>
De esta forma tenemos las clases detectadas, el número de ocurrencias, las etiquetas y desde luego podemos pintar sobre la foto para hacerlo más gráfico. Por ahora este modelo es limitado ya que utiliza COCO pero sin duda esperamos que más modelos se sumen a este y se encuentren nuevas utilidades.<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwj1UaDOjlapvzQYLJH5xzFHxw9aTx1ga9cLqpr19R3_O9WezbF2x_Qox1NWXpoLL-vDAcjjrwKD1r9DsmTzsh9LfXourAdgXCe2qAWsoZexU_GXT4JWMOX4kQsMNhbl4f7cDgGPwFATmz/s1600/object_detection.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="540" data-original-width="750" height="460" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwj1UaDOjlapvzQYLJH5xzFHxw9aTx1ga9cLqpr19R3_O9WezbF2x_Qox1NWXpoLL-vDAcjjrwKD1r9DsmTzsh9LfXourAdgXCe2qAWsoZexU_GXT4JWMOX4kQsMNhbl4f7cDgGPwFATmz/s640/object_detection.gif" width="640" /></a></div>
<div>
<br /></div>
<br />
*Por cierto, muy rápidamente podemos contar la cantidad de botellas que propone la foto… <br />
<div>
<br /></div>
<div>
Les dejo el segmento de implementación que hace esta operación en #TensorFlow. Pueden ver toda la implementación en la <a href="https://github.com/tensorflow/models/tree/master/object_detection">documentación oficial</a>.</div>
<div>
<br /></div>
<script src="https://gist.github.com/nbortolotti/6e2c27e475a27b7cd135e0f2c765e637.js"></script>
<br />
<div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">TensorFlow Object Detection API, cena con amigos</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolás Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-25549795447820763492017-07-03T16:59:00.002+02:002017-07-03T17:23:27.911+02:00Regresión lineal simple utilizando #tflearnTiempo atrás les compartí una pequeña <a href="https://nbortolotti.blogspot.ch/2017/04/regresion-lineal-simple-en-tensorflow.html">implementación</a> en donde se mostraba un ejemplo de regresión lineal univariable, utilizando el mecanismo puro de #tensorflow. En esta oportunidad la implementación se comparaba con la predicción tradicional que realizan soluciones como Google Spreadsheet. Como muchas veces, utilizar aprendizaje automático, incluso para modelo relativamente simples es un desafío, tratando mitigar esto, hoy les quiero compartir esta misma actividad implementada de manera similar, pero utilizando #tensorflow y una librería de alto <a href="https://github.com/tflearn/tflearn">nivel #tflearn</a> [creada por sobre #tensorflow]. Veamos si se percibe con menos complejidad.<br />
<br />
Versión de #tensorflow utilizada: 1.2.1<br />
<br />
<b>Recordemos que el objetivo es predecir la altura de los niños basada en su edad.</b><br />
<b><br /></b>
<span style="background-color: white;">Veamos la implementación completa, ustedes mismos pueden comparar la secuencia de pasos anteriormente implementada y esta nueva versión utilizando #tflearn.</span>
<span style="background-color: white; color: #757575; font-family: "roboto" , sans-serif; font-size: 15px;"><br /></span>
<br />
<script src="https://gist.github.com/nbortolotti/5e35398b603c842734b5855e20363c7c.js"></script>
<br />
De esta simple implementación podrían prestar atención a estos 3 momentos:<br />
<br />
1. Definición del modelo de regresión:<br />
<table class="highlight tab-size js-file-line-container" data-tab-size="8" style="background-color: white; border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; color: #24292e; font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; tab-size: 8;"><tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;"><td class="blob-code blob-code-inner js-file-line" id="file-linear_regression_tf-py-LC9" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><br class="Apple-interchange-newline" />
regression <span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span> tflearn.regression(linear, <span class="pl-v" style="box-sizing: border-box; color: #e36209;">optimizer</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-s" style="box-sizing: border-box; color: #032f62;"><span class="pl-pds" style="box-sizing: border-box;">'</span>sgd<span class="pl-pds" style="box-sizing: border-box;">'</span></span>, <span class="pl-v" style="box-sizing: border-box; color: #e36209;">loss</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-s" style="box-sizing: border-box; color: #032f62;"><span class="pl-pds" style="box-sizing: border-box;">'</span>mean_square<span class="pl-pds" style="box-sizing: border-box;">'</span></span>,
<span class="pl-v" style="box-sizing: border-box; color: #e36209;">metric</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-s" style="box-sizing: border-box; color: #032f62;"><span class="pl-pds" style="box-sizing: border-box;">'</span>R2<span class="pl-pds" style="box-sizing: border-box;">'</span></span>, <span class="pl-v" style="box-sizing: border-box; color: #e36209;">learning_rate</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">0.01</span>)
</td></tr>
</tbody></table>
2. Entrenamiento del modelo:<br />
<br />
<table class="highlight tab-size js-file-line-container" data-tab-size="8" style="background-color: white; border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; color: #24292e; font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; tab-size: 8;"><tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;"></tr>
<tr style="box-sizing: border-box;"><td class="blob-code blob-code-inner js-file-line" id="file-linear_regression_tf-py-LC11" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;">m.fit(variables[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">0</span>], variables[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">1</span>], <span class="pl-v" style="box-sizing: border-box; color: #e36209;">n_epoch</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">1500</span>, <span class="pl-v" style="box-sizing: border-box; color: #e36209;">show_metric</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">True</span>, <span class="pl-v" style="box-sizing: border-box; color: #e36209;">snapshot_epoch</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">=</span><span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">False</span>)</td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="12" id="file-linear_regression_tf-py-L12" style="box-sizing: border-box; color: rgba(27, 31, 35, 0.3); cursor: pointer; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; min-width: 50px; padding: 0px 10px; text-align: right; user-select: none; vertical-align: top; white-space: nowrap; width: 50px;"><br /></td></tr>
</tbody></table>
3. Predicción:<br />
<br />
<span class="pl-c1" style="background-color: white; box-sizing: border-box; color: #005cc5; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">print</span><span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">(</span><span class="pl-s" style="background-color: white; box-sizing: border-box; color: #032f62; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;"><span class="pl-pds" style="box-sizing: border-box;">"</span><span class="pl-cce" style="box-sizing: border-box;">\n</span> Child height predicted for 3.5 and 7 years<span class="pl-pds" style="box-sizing: border-box;">"</span></span><span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">)</span><br />
<span class="pl-c1" style="background-color: white; box-sizing: border-box; color: #005cc5; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">print</span><span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">(m.predict([</span><span class="pl-c1" style="background-color: white; box-sizing: border-box; color: #005cc5; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">3.5</span><span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">, </span><span class="pl-c1" style="background-color: white; box-sizing: border-box; color: #005cc5; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">7</span><span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">]))</span><br />
<br />
En este caso estamos utilizando, función de optimización stochastic gradient descent, la función de costo mean squared error, un ratio de aprendizaje de 0.01 y 1500 epocs/épocas/iteraciones. <br />
<br />
Veamos el resultado de la ejecución:<span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhmK5wt-NeC2rJgapKs9eDsLuhalhaSzCb31DOf91U2u7_axvIzELLC2EsATIvhHkF-UqK14KVAoyFBxoDj8OaEX-Gw0DlDBEkqH3gF4AtlRLze539wFF2cKP0rhgSZDaWPpToF4F9LGY2/s1600/tflearn_regression_1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="546" data-original-width="992" height="352" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhmK5wt-NeC2rJgapKs9eDsLuhalhaSzCb31DOf91U2u7_axvIzELLC2EsATIvhHkF-UqK14KVAoyFBxoDj8OaEX-Gw0DlDBEkqH3gF4AtlRLze539wFF2cKP0rhgSZDaWPpToF4F9LGY2/s640/tflearn_regression_1.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 ejecución del ejemplo</td></tr>
</tbody></table>
Veamos que dice #TensorBoard sobre la ejecución de este modelo:<span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvwyPfDBh45xp5CaDRucia8btLKXzcmSdYkRcnBOdDimJalOfMLMeXfcReNcQKmbqALL2gKO4gPidjeDin4AMeyMeFmgbWDXswWpT5L-dZ5lJcFvck9wpzXsDP8MatFcaRhAx2T5FvwVIA/s1600/tflearn_regression_3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="648" data-original-width="1600" height="257" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvwyPfDBh45xp5CaDRucia8btLKXzcmSdYkRcnBOdDimJalOfMLMeXfcReNcQKmbqALL2gKO4gPidjeDin4AMeyMeFmgbWDXswWpT5L-dZ5lJcFvck9wpzXsDP8MatFcaRhAx2T5FvwVIA/s640/tflearn_regression_3.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig. 2 Representación del gráfico en TensorBoard</td></tr>
</tbody></table>
También podemos analizar la función de costo y su proyección pasando las epocs:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSbY4Etr7ArODR55V2jQFKIDLveBfM9rxZ4rP-v1xBybwPxny0KSYBcv7UQ57JUhXLbvQ8ADVxdhDxqW8RNDDT-tx_VLrOfXEl343bem760fB0A3F_cROc4mOSh8fXISIlhJP3X0AHhA3M/s1600/tflearn_regression_2.png" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSbY4Etr7ArODR55V2jQFKIDLveBfM9rxZ4rP-v1xBybwPxny0KSYBcv7UQ57JUhXLbvQ8ADVxdhDxqW8RNDDT-tx_VLrOfXEl343bem760fB0A3F_cROc4mOSh8fXISIlhJP3X0AHhA3M/s640/tflearn_regression_2.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.3 Análisis de la función de costo en TensorBoard</td></tr>
</tbody></table>
<div>
<div class="separator" style="clear: both; text-align: left;">
Seguramente has encontrado más simple este modelo de implementación. </div>
<span style="background-color: white; color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;"><br /></span></div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Regresión lineal simple utilizando #tflearn</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-13592803039435794592017-05-08T15:51:00.005+02:002017-05-08T15:51:56.063+02:00Las librerías Javascript más populares según #httparchive Hoy me hice una pregunta que muchos de ustedes quizás tienen en mente... Cuál es la librería #Javascript más utilizada en nuestra Web Actual. Es complicado responder esta pregunta, pero para generar una aproximación, nosotros podríamos trabajar con la información que provee #httparchive. [se están analizando unos 500k sitios] y crear en unos minutos un simple análisis de datos.<br />
<br />
Rick Viscomi en este artículo menciona, que se agrega una nueva métrica personalizada que permite realizar nuevos análisis, esto nos va a servir para tener una idea de las librerías JS que utilizan estos sitios analizados por #httparchive. [<a href="https://discuss.httparchive.org/t/javascript-library-detection/955">https://discuss.httparchive.org/t/javascript-library-detection/955</a>]<br />
<br />
Veamos un top-ten de las librerías JS utilizadas:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8KTU9D7J7VHFYxkrULcX9dYbJwzYzH4uxn4v-ZUyp0kzc5T4YLYWsVPIgxpLaBhadb6pnxMYhUHdcizEnvbMjB6FRipvlJTLdtud3psIIJp0P5Rann4MDEbBGbUUBeIUJaHrgu-T_YCED/s1600/httparchive_bigquery_.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8KTU9D7J7VHFYxkrULcX9dYbJwzYzH4uxn4v-ZUyp0kzc5T4YLYWsVPIgxpLaBhadb6pnxMYhUHdcizEnvbMjB6FRipvlJTLdtud3psIIJp0P5Rann4MDEbBGbUUBeIUJaHrgu-T_YCED/s640/httparchive_bigquery_.png" width="640" /></a></div>
Resultados:<br />
<div>
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ-HWcWXOXLEPwqXufgoO3pWAAky88wO5TaWuCbvGNmlvEKUUpk3tyQwU4hn-J-wJowKXRSSyZqDC8Z0ZbzZlq1xuEOL5fTcH6LNSxgoLhZIvPUZYO7su_aYQR-83hiC_m1tTgFJtcRzyW/s1600/httparchive_bigquery_1.png"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ-HWcWXOXLEPwqXufgoO3pWAAky88wO5TaWuCbvGNmlvEKUUpk3tyQwU4hn-J-wJowKXRSSyZqDC8Z0ZbzZlq1xuEOL5fTcH6LNSxgoLhZIvPUZYO7su_aYQR-83hiC_m1tTgFJtcRzyW/s640/httparchive_bigquery_1.png" /></a><br />
<br />
Podemos pasar estos valores a una representación visual y tenemos,<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgav-i6pYnmYEwqh24ZjqbgVOMcv33nH64jmBwF_PKNShtLj7CfIIDxIZjl0c7yZzyWxVwGV51opXeWJqzkhw0yAAwswFqrK1QRzXzTstStQ77Lta6f_-k9J7_5OKagRlg82Y2LA935JScL/s1600/httparchive_bigquery_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="354" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgav-i6pYnmYEwqh24ZjqbgVOMcv33nH64jmBwF_PKNShtLj7CfIIDxIZjl0c7yZzyWxVwGV51opXeWJqzkhw0yAAwswFqrK1QRzXzTstStQ77Lta6f_-k9J7_5OKagRlg82Y2LA935JScL/s640/httparchive_bigquery_2.png" width="640" /></a></div>
Tabla analizada: 2017_04_15_js_libs</div>
<div>
<br />
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Las librerías Javascript más populares según #httparchive </span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>. <br />
<div>
<br /></div>
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-7611348962871691882017-04-27T12:11:00.000+02:002017-04-27T12:11:01.927+02:00Entendiendo la personalidad de mi equipo, cual es tu estilo?Cada equipo es una mezcla de personalidades, muchos líderes se preguntan cómo obtener la mejor combinación de las mismas y optimizar el equipo de trabajo. <br />
<br />
También ocurre un comportamiento frecuente, muchos equipos no están a la altura de su potencial, y una posible explicación es que los líderes no saben cómo manejar la diferencia en cómo las personas se acercan a su trabajo. <br />
<br />
Para abordar esta discusión me pareció muy interesante la siguiente propuesta de "Suzanne Johnson Vickberg and Kim Christfort, en el trabajo Pioneers, Drivers, integrators, & Guardians" donde se proponen 4 estilos de trabajo:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilYidNldu4o6FIJ9u3hwHa6ETzo1908mKArQSWQvaHwbYF5Qseceos_ulqxCc2oExPq-Omcll1eW8Dbo9MmHuMs11pmPggRKzOyjjuQ5HFYfFL_MC1hy1St4HC1osfl21mGG5pVnOM2YJF/s1600/integrators_cover.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="604" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilYidNldu4o6FIJ9u3hwHa6ETzo1908mKArQSWQvaHwbYF5Qseceos_ulqxCc2oExPq-Omcll1eW8Dbo9MmHuMs11pmPggRKzOyjjuQ5HFYfFL_MC1hy1St4HC1osfl21mGG5pVnOM2YJF/s640/integrators_cover.png" width="640" /></a></div>
<br />
<b>Pioneros</b>: valoran las posibilidades, la energía (chispas de energía) y la imaginación en sus equipos. Ellos creen que los riesgos valen la pena. Su enfoque es BigPicture. Ellos son atraídos a las nuevas ideas, enfoques creativos.<br />
<br />
<b>Guardianes</b>: valoran la estabilidad, ponen orden y rigor. Son pragmáticos, y no se atreven a abrazar el riesgo. Datos y hechos son requisitos básicos para ellos, y los detalles son importantes. Piensan que tiene sentido para aprender del pasado.<br />
<br />
<b>Conductores</b>: valoran los desafíos y generan momentum(impulso). La obtención de resultados es importante. Los conductores tienden a ver los problemas como blanco y negro y hacen frente a los problemas, armados con lógica y datos.<br />
<div>
<br />
<b>Integradores</b>: valoran la conexión y unen a los equipos. Las relaciones y la responsabilidad con el grupo son primordiales. Los integradores tienden a creer que la mayoría de las cosas son relativas. Son diplomáticos y enfocados en ganar consenso.</div>
<div>
<br /></div>
<div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span id="docs-internal-guid-884b8d6e-aec3-b3d5-9812-c2a5d6ca027e">Identificar los perfiles es solo el comienzo del tema, cuales son la sugerencias para administrar de manera óptima estos perfiles? </span></div>
<span id="docs-internal-guid-884b8d6e-aec3-b3d5-9812-c2a5d6ca027e">
</span>
<br />
<ol><span id="docs-internal-guid-884b8d6e-aec3-b3d5-9812-c2a5d6ca027e">
<li>Acerque perfiles opuestos</li>
<li>Balance de perfiles para evitar cascadas. (las cascadas se desarrollan cuando una mayoría influencia al resto de perfiles sobre una idea)</li>
<li>Prestar mucha atención a sus introvertidos sensibles.</li>
</span></ol>
<span id="docs-internal-guid-884b8d6e-aec3-b3d5-9812-c2a5d6ca027e">
Lo ideal sería aprovechar al máximo la diversidad cognitiva de su equipo y organización, vamos a abordar el caso de acercar perfiles opuestos.</span></div>
<div>
<br />
Experiencia cruzada <b>Conductor</b>:<br />
Un conductor explicó por qué no le gusta trabajar con Integradores: "Me resulta agotador tener toda la charla para hacer que todos se sientan bien trabajando juntos. Sólo quiero hacer las cosas, dar una respuesta honesta y directa, y seguir adelante. Tener que preocuparme por sentimientos sensibles me hace más lento"</div>
<br />
Experiencia cruzada <b>Integrador</b>:<br />
<div>
Un integrador en su relación con conductores dijo: "Necesito procesar las cosas para obtener el contexto de fondo, el panorama general. Los conductores a menudo hablan en código o fragmentos de pensamiento que necesitamos traducir "</div>
<br />
Experiencia cruzada <b>Guardián</b>:<br />
<div>
"Siempre estoy pensando en cómo voy a implementar algo ... y mientras los Pioneros tienen grandes ideas, normalmente no pueden ser molestados para discutir cómo ejecutarlas. Luego, si el resultado no coincide con su visión, ¡están frustrados!"</div>
<br />
Experiencia cruzada <b>Pionero</b>:<br />
<div>
Y un Pionero admitió: "Me llevó un tiempo y fue muy difícil ajustarme al estilo de un Guardián. Soy decisivo y me gusta generar ideas sin juicio. Los guardianes pueden parecer críticos y no permiten que fluya la creatividad ".</div>
<div>
<br /></div>
A pesar de los estragos que pueden causar las diferencias en el rendimiento del equipo, <i>estilos opuestos se equilibran entre sí</i>. Sin embargo, esto lleva tiempo y esfuerzo.<br />
<br />
Los invito a probar de forma práctica el modelo tratando de determinar su estilo y el de sus equipos…<br />
<br />
<b>Cual es tu estilo?</b><br />
<div>
Marque los rasgos que generalmente se aplican (teniendo en cuenta que probablemente se comportan de manera diferente en diferentes grupos y situaciones). Calcule los rasgos relevantes en cada categoría para obtener un indicador aproximado de los estilos en los que manifiestan con mayor frecuencia.<br />
<br />
<div>
<div dir="ltr" style="margin-left: 0pt;">
<table style="table-layout: fixed;">
<tbody>
<tr>
<td style="border: 1px solid black; width: 25%;"><ul>
<li>Extrovertido</li>
<li>Enfocado en el panorama general </li>
<li>Espontáneo</li>
<li>Riesgoso</li>
<li>Adaptable</li>
<li>Imaginativo</li>
</ul>
</td>
<td style="border: 1px solid black; width: 25%;"><ul>
<li>Diplomático</li>
<li>Empático</li>
<li>Tradicional</li>
<li>Orientado a las relaciones</li>
<li>Intrínsecamente motivado</li>
<li>No conflictivo</li>
</ul>
</td>
<td style="border: 1px solid black; width: 25%;"><ul>
<li>Cuantitativo</li>
<li>Lógico Enfocado</li>
<li>Competitivo</li>
<li>Experimental</li>
<li>Profundamente curioso</li>
</ul>
</td>
<td style="border: 1px solid black; width: 25%;"><ul>
<li>Metódico</li>
<li>Reservado</li>
<li>Detallista</li>
<li>Práctico</li>
<li>Estructurado</li>
<li>Leal</li>
</ul>
</td>
</tr>
<tr>
<td style="border: 1px solid black;"><div style="text-align: center;">
<b>Pionero</b></div>
</td>
<td style="border: 1px solid black;"><div style="text-align: center;">
<b>Integrador</b></div>
</td>
<td style="border: 1px solid black;"><div style="text-align: center;">
<b>Conductor</b></div>
</td>
<td style="border: 1px solid black;"><div style="text-align: center;">
<b>Guardián</b></div>
</td>
</tr>
</tbody></table>
</div>
<span id="docs-internal-guid-884b8d6e-aec7-5194-f933-f43d9f0ed382">
</span></div>
<div>
<br /></div>
<div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Entendiendo la personalidad de mi equipo, cual es tu estilo?</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.</div>
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-30936868201674662752017-04-17T22:38:00.003+02:002017-04-17T22:44:59.082+02:00Regresión lineal simple en #TensorFlow, aprendizaje automático para mayor exactitudEn estadística tradicional un modelo muy utilizado para predicciones, es el modelo de regresión lineal (siempre y cuando los valores permitan aplicar este modelo). En este artículo vamos a tratar de responder una pregunta simple. ¿Un modelo de aprendizaje automático nos puede ayudar a mejorar nuestro estudio de variables? Si necesitas más información sobre el concepto de #RegresionLineal puede utilizar este <a href="https://es.wikipedia.org/wiki/Regresi%C3%B3n_lineal">link</a>.<br />
<div>
<br /></div>
<div>
Para nuestro estudio, vamos a analizar la edad de niños en el eje “x” y la altura de los mismos en el eje “y”. Intentaremos predecir la altura de los niños basada en su edad, aplicando regresión lineal simple. Fuente académica de este ejemplo <a href="http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=MachineLearning&doc=exercises/ex2/ex2.html">link</a>.</div>
<div>
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57">Vamos a utilizar una planilla de cálculo para explorar la situación de manera tradicional:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57"><span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><img height="304" src="https://lh6.googleusercontent.com/MIBgbJ176hymJnH6_q7fLlN1e7Vudx3v-UTMGaCQWsgjCPy7YkTsxf0h3CWhCw1cjTFxMta4p8fnyhsfGjMIl9ZmcLhlFo5xnIc_OCxT0OJ3NgwIcb5PYS1g7YbpACkvBt9Ip_et" style="border: none; transform: rotate(0rad);" width="602" /></span></span></div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57">
</span>
<br />
<div>
</div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57">
</span>
<br />
<div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span></span></div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57">
</span>
<div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57">Ahora bien, ¿Qué buscamos con el modelo de aprendizaje automático?. Recordando nuestra función lineal nos enfocaremos en W y b.</span></div>
<span id="docs-internal-guid-dbfc9d7a-7d3d-6dfd-f1f0-4e1b8ef55d57">
</span></div>
<div>
<blockquote class="tr_bq" style="text-align: center;">
<span style="font-size: large;">y = <b style="color: red;">W</b>x +<b><span style="color: red;">b</span></b></span></blockquote>
</div>
Buscamos aprender para encontrar los mejores <b>W</b> y <b>b</b>. En la siguiente figura se muestra la representación simple de una regresión lineal.<br />
<div>
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><img height="333" src="https://docs.google.com/drawings/u/0/d/s9hYaiQsA1Hh2uZO3iKbuwg/image?w=410&h=333&rev=48&ac=1" style="border: none; transform: rotate(0rad);" width="410" /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-dbfc9d7a-7d3e-9da4-ffab-38eb9ae286df"></span></span></div>
Los mejores <b>W</b> y <b>b</b> reducen el costo. Como muestra la siguiente figura, este será el objetivo del modelo de aprendizaje automático.<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-weight: 400; margin-left: 1em; margin-right: 1em; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img height="333" src="https://docs.google.com/drawings/u/0/d/s-rQnXUMuONsmFuulRQqbPg/image?w=410&h=333&rev=59&ac=1" style="border: none; transform: rotate(0rad);" width="410" /></span></div>
Con el menor costo, mejoramos radicalmente la predicción, representado en la siguiente figura:<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><img height="333" src="https://docs.google.com/drawings/u/0/d/sCl9iH_hz-jc-zr4oD7KD-A/image?w=410&h=333&rev=18&ac=1" style="border: none; transform: rotate(0rad);" width="410" /></span></div>
<div>
<span id="docs-internal-guid-dbfc9d7a-7d5e-82e3-15e2-d25aa38c0a98"></span>Nuestro pregunta central: "Vamos a preguntar por la edad y buscamos la respuesta de la altura mejor ajustada"<br />
<div class="separator" style="clear: both;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-weight: 400; margin-left: 1em; margin-right: 1em; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
</div>
Llegó la hora de crear el modelo en #TensorFlow:<br />
<br />
<b>Valores de ingreso:</b><br />
<span style="font-size: x-small;">X = tf.placeholder(tf.float32, [m, n])<br />Y = tf.placeholder(tf.float32, [m, 1])</span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><span style="color: #666600; font-family: "consolas"; font-size: 9pt; vertical-align: baseline;"><br /></span></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><span id="docs-internal-guid-dbfc9d7a-7d44-56a3-b109-2d9a32c04d70"></span></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>Peso y la perturbación aleatoria:</b></span></div>
<span style="font-size: x-small;">W = tf.Variable(tf.zeros([n, 1], dtype=np.float32), name="weight")<br />b = tf.Variable(tf.zeros([1], dtype=np.float32), name="bias")</span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><span style="color: #666600; font-family: "consolas"; font-size: 9pt; vertical-align: baseline;"><br /></span></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><b>Modelo Lineal:</b></span></span></div>
<span style="font-size: x-small;">with tf.name_scope("linear_Wx_b") as scope:<br /> activation = tf.add(tf.matmul(X, W), b)</span><br />
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><b>Costo:</b></span></span></div>
<span style="font-size: x-small;">with tf.name_scope("cost") as scope:<br /> cost = tf.reduce_sum(tf.square(activation - Y)) / (2 * m)<br /> tf.summary.scalar("cost", cost)</span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><span style="font-family: "consolas"; font-size: 9pt; vertical-align: baseline;"><br /></span></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; vertical-align: baseline;"><b>Entrenamiento:</b></span></span></div>
<span style="font-size: x-small;">with tf.name_scope("train") as scope: </span><br />
<div>
<span style="font-size: x-small;"> optimizer = tf.train.GradientDescentOptimizer(0.07).minimize(cost)</span><br />
<div>
<div>
<br /></div>
<div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b>Luego generamos la sesión en #TensorFlow:</b><br />
<span style="font-size: x-small;">with tf.Session() as sess:</span></div>
<span style="font-size: x-small;"> merged = tf.summary.merge_all()<br /> writer = tf.summary.FileWriter(log_file, sess.graph)<br /> init = tf.global_variables_initializer()<br /> sess.run(init)<br /> for step in range(1500):<br /> result, _ = sess.run([merged, optimizer], feed_dict={X: np.asarray(train_X), Y: np.asarray(train_Y)})</span></div>
<div>
<span style="font-size: x-small;"> writer.add_summary(result, step)</span></div>
<div>
<span style="font-size: x-small;"><br /></span>
Vamos a iterar 1500 veces el modelo, luego pueden evaluar diferentes configuraciones y desde luego variar el ratio de aprendizaje que por el momento está fijado en 0.07.</div>
<div>
<br /></div>
<div>
<span style="font-size: x-small;">print "Prediction for 3.5 years"<br />predict_X = np.array([3.5], dtype=np.float32).reshape([1, 1])<br />predict_X = (predict_X - mean) / std<br />predict_Y = tf.add(tf.matmul(predict_X, W), b)print "Child height(Y) =", sess.run(predict_Y)</span><br />
<div>
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: "consolas"; font-size: 9pt; vertical-align: baseline;"><br /></span></span></div>
Esto nos entrega un valor de <b>0.9737 </b>(expresa la altura en metros) Pueden validar académicamente la solución del ejercicio en este <a href="http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=MachineLearning&doc=exercises/ex2/ex2.html">link</a>.<br />
<br />
Aquí la implementación de la solución:</div>
<div>
<br />
Además incluí #TensorBoard en nuestro estudio para poder analizar:el modelo con más detalles:<br />
<div>
<span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: "consolas"; font-size: 9pt; vertical-align: baseline;"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline;"><img height="476" src="https://lh4.googleusercontent.com/yJC62vKURb95Pu0-iZo79r7_swjw3Rl6aOHJXUgHsLOtrVuU2UBMKbKI8mJSHk3tiBTrz0uPn3Jde-0E1XQJAv2SGwWMJeTofqTwEfm6s0vtYjaAE04g3jZyDiQNZdKs3JJ9bi7D" style="border: none; transform: rotate(0rad);" width="602" /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
El trazado de la función de costo:</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial"; font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline;"><span id="docs-internal-guid-dbfc9d7a-7d4a-30c0-635a-fd956ce4bf87"></span></span><span style="font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><img height="291" src="https://lh6.googleusercontent.com/dcU60_CnHqwlCshmsbYTcUyJcldNkioHLrv3CsCXoIOaFWLF6zqzVRa803I6NvYL0TYEduv9L81XoMcj0akkjNU4NBbtElxtis2PgxT2L_BR9wSHkdUe5x0nA9kfLcd2QXB4TUVI" style="border: none; transform: rotate(0rad);" width="602" /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: 11pt; margin-left: 1em; margin-right: 1em; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: "arial"; font-size: 11pt; vertical-align: baseline;"><br /></span></span></div>
<b>Nota</b>: he seleccionado muchos valores y configuraciones estándares, con el objetivo de simplificar la explicación, luego el lector puede modificar a gusto los elementos de estudio.<br />
<br />
Si comparamos nuestro estudio inicial utilizando una planilla tradicional y nuestro modelo automático, es evidente que tenemos mucha mayor exactitud con nuestro modelo automático y además toda la escala para ingerir un volumen mayor de datos y crear mejores predicciones. Están listos para más magia?<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt4txC78mwMe5p3Yi5G-yqWNTF_RL8-E7AUriyLeJepZWs0wEohmNCiDBxa0Hb4nXEzyVnIkyDWF5slyy7EhIDL7EO3cXdyT-FTHxZh8TZVHDUQl6R50_lk2mlinQg0q5lPeqc25rAoIBF/s1600/linear_regression_implement.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="362" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt4txC78mwMe5p3Yi5G-yqWNTF_RL8-E7AUriyLeJepZWs0wEohmNCiDBxa0Hb4nXEzyVnIkyDWF5slyy7EhIDL7EO3cXdyT-FTHxZh8TZVHDUQl6R50_lk2mlinQg0q5lPeqc25rAoIBF/s640/linear_regression_implement.gif" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-JJiXdeTjMzMT30LJp0eiwZHPofzaao7qb9NbbSYfxnm_kT72SbqQ5FUCt7AFXYv8y2YtOd5LWefg407MiuULb13BoqX6MXKrjWNYAcu3pfjtbUnvd2OMa_DeSUg9cC_y0muG2gNpofKA/s1600/linear_regression_board.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="422" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-JJiXdeTjMzMT30LJp0eiwZHPofzaao7qb9NbbSYfxnm_kT72SbqQ5FUCt7AFXYv8y2YtOd5LWefg407MiuULb13BoqX6MXKrjWNYAcu3pfjtbUnvd2OMa_DeSUg9cC_y0muG2gNpofKA/s640/linear_regression_board.gif" width="640" /></a></div>
</div>
<div>
<br /></div>
</div>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Regresión lineal simple en #TensorFlow, aprendizaje automático para mayor exactitud</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.
</div>
</div>
Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-35421333594358668772017-02-06T05:30:00.003+01:002017-02-06T05:30:45.736+01:00TensorFlow, una simple aproximación al calculo numérico en Python<span style="background-color: #fefefe; font-family: "tahoma" , "arial" , "helvetica" , sans-serif; font-size: 14px;">Hace algún tiempo un presidente de Estados Unidos decía algo como esto sobre la automatización..."Si lo entendemos, si lo planeamos, si lo aplicamos bien, la automatización no será un destructor de trabajo ni una familia desplazada. En su lugar, esta puede eliminar la tontería de la obra del hombre y darle más de lo que el hombre ha tenido antes". [</span><a href="https://hbr.org/2017/02/25-percent-of-ceos-time-is-spent-on-tasks-machines-could-do">25% of CEOs’ Time Is Spent on Tasks Machines Could Do</a>]. <span style="background-color: #fefefe; font-family: "tahoma" , "arial" , "helvetica" , sans-serif; font-size: 14px;">El presidente de los Estados Unidos que dijo esas palabras fue Lyndon B. Johnson, en 1964.</span><br />
<span style="background-color: #fefefe; font-family: "tahoma" , "arial" , "helvetica" , sans-serif; font-size: 14px;"><br /></span>
<span style="background-color: #fefefe;"><span style="font-family: "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="font-size: 14px;">Podemos pasar algunos pasos y llegar al aprendizaje automático, partiendo desde el concepto de automatización, lo bueno sería contar con buenos elementos, de código fuente abierto, para iniciar este apasionante camino. En este sector se mueve </span></span></span><span style="background-color: white;"><a href="https://www.tensorflow.org/" style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 14px;">TensorFlow</a><span style="font-family: "tahoma" , "arial" , "helvetica" , sans-serif;"><span style="font-size: 14px;">, una biblioteca de software de código abierto para computación numérica que utiliza gráficos de flujo de datos. Y como hablamos de primeros pasos, vamos a ver un ejemplo simple de como manejar un cálculo numérico muy simple dentro de la arquitectura #TensorFlow.</span></span></span><br />
<br />
<script src="https://gist.github.com/nbortolotti/2dff31e6af8be6d3fb857b96b99f8af5.js"></script>
El comportamiento sería el siguiente:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2JKjHWK06S7s_0NlP-JPkV72UX-Te3ku2HciQUTit1j9Vxp1jSkbHdoMwGq3f2lRazabqQ3OGSW-4GJy7c15ayup5NhOZqU6lL1zvUVamky4Q9PftYttvny9cH8VZ-5vW7KrrFnrDWGxs/s1600/implementation.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2JKjHWK06S7s_0NlP-JPkV72UX-Te3ku2HciQUTit1j9Vxp1jSkbHdoMwGq3f2lRazabqQ3OGSW-4GJy7c15ayup5NhOZqU6lL1zvUVamky4Q9PftYttvny9cH8VZ-5vW7KrrFnrDWGxs/s640/implementation.gif" width="640" /></a></div>
<br />
También podemos ver el gráfico desde #TensorBoard:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjctraf9jGcYOIBncsKh9dWuonV9xabsbcJej8QRfu8PWgk74RUz5dx94DnNTMdm0sDgxs-SOgF_ZOExENDxhQRViTYsILQhOA8brPcCXhzg0RmXtZB8Jl3j4VR-avi0p7Hydjn_UiL_Am2/s1600/tensorboard.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="512" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjctraf9jGcYOIBncsKh9dWuonV9xabsbcJej8QRfu8PWgk74RUz5dx94DnNTMdm0sDgxs-SOgF_ZOExENDxhQRViTYsILQhOA8brPcCXhzg0RmXtZB8Jl3j4VR-avi0p7Hydjn_UiL_Am2/s640/tensorboard.gif" width="640" /></a></div>
<br />
Para quienes no conocían una implementación en #Tensorflow espero que puedan aplicar sus modelos de manera transparente, con esta simple demostración presentada.<br />
<br />
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">TensorFlow, una simple aproximación al calculo numérico en Python</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0tag:blogger.com,1999:blog-1959802855612618678.post-10004116835500697712017-01-16T23:57:00.002+01:002017-01-16T23:57:49.111+01:00La eficacia del contenido en la web actual #Bigquery #httparchive #gzip_scoreOptimizar la eficacia del contenido para los portales web/web móviles actuales parecería algo asumido pero, ¿podemos asegurar eso?<br />
<div>
<br /></div>
<div>
En el portal de developers de #Google #Web #Fundamentals pueden encontrar muy buenos artículos. <a href="https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/">Visión general</a> de la optimización de contenidos. También pueden revisar la <a href="https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/optimize-encoding-and-transfer">sección</a> donde se explica la optimización en la codificación y transferencia de recursos basados en texto. Parece directamente asumido que la compresión gzip está activa en todos los portales de mayor impacto, solo quería validar esta presunción. ¿Como?</div>
<div>
<br /></div>
<div>
Vamos a utilizar los datos portados a BigQuery de <a href="http://httparchive.org/">httparchive.org</a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit5CskKc1yQ4lMhkLmVCA6nTzNxhyphenhyphenm7RN69dD7CP_6Uevy0jilISOrgFLWcnHTjDsuwLt7NGDLV1UoY7F8Jk7uFc4qcz8jWpOM_zBiKrgfRDh681W3_UJx7YrxMhpOrVY7hg4Km-D3pIpP/s1600/http_archive_bigquery.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit5CskKc1yQ4lMhkLmVCA6nTzNxhyphenhyphenm7RN69dD7CP_6Uevy0jilISOrgFLWcnHTjDsuwLt7NGDLV1UoY7F8Jk7uFc4qcz8jWpOM_zBiKrgfRDh681W3_UJx7YrxMhpOrVY7hg4Km-D3pIpP/s400/http_archive_bigquery.png" width="366" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Utilizaremos la sección donde se registran los HARs de análisis realizados y la tabla de 2016_01_01_android_pages. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqax1IJT89yVA3CrsHJ_WOZubRLp1bbLG_ttPJD5RBaGAZA3-IBrypu3TYz9ruPDH8SNLhF1EvqDYEko79EgaQY2jzA_4hyXWq3PRCfVSapUM-zpEawf5tSvgVErNOt01ya0vigbDDR8BT/s1600/http_archive_bigquery_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="306" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqax1IJT89yVA3CrsHJ_WOZubRLp1bbLG_ttPJD5RBaGAZA3-IBrypu3TYz9ruPDH8SNLhF1EvqDYEko79EgaQY2jzA_4hyXWq3PRCfVSapUM-zpEawf5tSvgVErNOt01ya0vigbDDR8BT/s640/http_archive_bigquery_1.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div>
Solo tenemos la url analizada y el payload en json, con un diseño como este:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMxUDHe38NNenE2OJMMfGb0MiEBxUfJ94tq-vUMl5ob9mAy2Ugjgfb0IRWI-q3QoTUz3rMcPwBN82OpZ6uonj5-FuvK3DgP0vNfpMjYRJGyzBX8iBE5fAZPxhmAmkaO54_RrZOy6AEH_yb/s1600/http_archive_bigquery_json_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="514" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMxUDHe38NNenE2OJMMfGb0MiEBxUfJ94tq-vUMl5ob9mAy2Ugjgfb0IRWI-q3QoTUz3rMcPwBN82OpZ6uonj5-FuvK3DgP0vNfpMjYRJGyzBX8iBE5fAZPxhmAmkaO54_RrZOy6AEH_yb/s640/http_archive_bigquery_json_2.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Como el análisis está realizado con WPT podemos obtener directamente el <b>gzip_score</b>. ¿Como se imaginan esto? </div>
<div class="separator" style="clear: both; text-align: left;">
Con BigQuery es muy simple:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<script src="https://gist.github.com/nbortolotti/bc00dc93cae207831559e1fa2785a285.js"></script>
<br />
<div>
Utilizando la función <b>JSON_EXTRACT(payload, '$._score_gzip')</b> podemos obtener el score propuesto en cada HAR, luego solo agrupar y ordenar. Veamos que dicen los <b>#1000</b> sitios con mejor ranking. </div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_I4sIvqA4Eqs-YJUm0Dzndb1kvXMb47GZX1iq3WLrzZ13ZElX4xR1WsZ6_EKGzW3AAXgypZMChjTf9yKtcFgaWwzb78AvAnkajKxiuvejHGYmBAxmN78e5GPwp3fB6kovLTy7q6tWBm-d/s1600/http_archive_bigquery_chart.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="412" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_I4sIvqA4Eqs-YJUm0Dzndb1kvXMb47GZX1iq3WLrzZ13ZElX4xR1WsZ6_EKGzW3AAXgypZMChjTf9yKtcFgaWwzb78AvAnkajKxiuvejHGYmBAxmN78e5GPwp3fB6kovLTy7q6tWBm-d/s640/http_archive_bigquery_chart.png" width="640" /></a></div>
<br />
<br />
Que tal si ahora analizamos este snapshot con todas las url analizadas y el porcentual que tienen gzip_score mayor o igual a 95?<br />
<br />
URL estudiadas: <b>4751</b><br />
URL con gzip_score => 95: <b>887</b><span style="font-family: "arial" , sans-serif; font-size: 13px; text-align: right; white-space: nowrap;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbINze0Xcr5FWUvWfI0WHSxSlc2MQ6wVds7ky7LrLelDEB-qgKNVfkGa8bipSoEvLydnWzt0AEzNAWwq6IJI15yrNg6w5q1h69_lsl6gGn0tqJjLf76mqEvGY-_DMpDA0ide8qRhBWRhVp/s1600/http_archive_bigquery_chart_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="435" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbINze0Xcr5FWUvWfI0WHSxSlc2MQ6wVds7ky7LrLelDEB-qgKNVfkGa8bipSoEvLydnWzt0AEzNAWwq6IJI15yrNg6w5q1h69_lsl6gGn0tqJjLf76mqEvGY-_DMpDA0ide8qRhBWRhVp/s640/http_archive_bigquery_chart_2.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<span style="font-family: "arial" , sans-serif; font-size: 13px; text-align: right; white-space: nowrap;"><br /></span>
<span style="font-family: "arial" , sans-serif; font-size: 13px; text-align: right; white-space: nowrap;"><br /></span>
<a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" style="border-width: 0;" /></a><br />
<span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">La eficacia del contenido en la web actual #Bigquery #httparchive #gzip_score</span> por <span property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#">Nicolas Bortolotti</span> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-sa/4.0/" rel="license">Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional</a>.Nicolas Bortolottihttp://www.blogger.com/profile/00009231544375156994noreply@blogger.com0