tag:blogger.com,1999:blog-3454010841544299652024-03-18T07:50:05.661-07:00TEKNE - TECHNEYou will find my technical articles and translations on software in this article. My areas of interest include JAVA - J2EE with all its aspects, specially EJB3, Struts, JSF, Spring, WebServices and other frameworks.Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comBlogger357125tag:blogger.com,1999:blog-345401084154429965.post-63911045536794562782024-03-18T07:48:00.000-07:002024-03-18T07:49:11.750-07:00simplest Python WEB app for implementing neural networks<p> Making a machine learning app is not enough by itself. You have to package it and SELL it, or
present in a commodity form. This is an
example of a simplest WEB app that can be changed to run a neural network
PREdICT command on the WEB.</p><p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Open the POWERSHELL app (from ANACONDA)<o:p></o:p></p>
<div style="background: white; border: solid #E3E3E3 1.0pt; mso-border-alt: solid #E3E3E3 .25pt; mso-element: para-border-div; padding: 0in 0in 0in 0in;">
<p class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: normal; margin: 15pt 0in; padding: 0in;"><span style="color: #0d0d0d; font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">First, make sure you
have Django installed. You can install it using pip:<o:p></o:p></span></p>
<p class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt;">pip install django</span><span style="color: #0d0d0d; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p></o:p></span></p>
<p class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="border: solid #E3E3E3 1.0pt; color: white; font-family: "inherit","serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 1.0pt;">pip install django</span><span style="color: #0d0d0d; font-family: "Courier New"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p></o:p></span></p>
</div>
<p class="MsoNormal">Create a working directory:
C:\Users\ars\ARStensorflow\0icron\interactive<o:p></o:p></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">django-admin startproject myproject<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #e9950c; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">cd</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
myproject<o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">python manage.py
startapp myapp<o:p></o:p></span></p>
<p class="MsoNormal">This creates:<o:p></o:p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLl1bGdjIhHHAnUjQa1kWsqZNwM1O3f8jgAq8s2hjjpATAWh2W5qmWzuVTubf62XD5nd_KnII93fI646T_nwyD8ZzwErDnLsLWVWtehC7Knk_AEK6h-Is7AR0HyVdziUO03QS6ib91BqJWtQ4Uxu26bS-mEYKs8PqiFMXAViEagaWOi3o7sEXwZqoJJ3bQ/s930/interactive.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="302" data-original-width="930" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLl1bGdjIhHHAnUjQa1kWsqZNwM1O3f8jgAq8s2hjjpATAWh2W5qmWzuVTubf62XD5nd_KnII93fI646T_nwyD8ZzwErDnLsLWVWtehC7Knk_AEK6h-Is7AR0HyVdziUO03QS6ib91BqJWtQ4Uxu26bS-mEYKs8PqiFMXAViEagaWOi3o7sEXwZqoJJ3bQ/w640-h208/interactive.jpg" width="640" /></a></div><br /><p class="MsoNormal"><br /></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">Now, let's define the view for our web application. Open the
file </span><code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; box-sizing: border-box; white-space-collapse: preserve;"><b><span style="background: white; border: solid #E3E3E3 1.0pt; color: #0d0d0d; font-size: 10.5pt; line-height: 115%; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; padding: 0in;">myapp/views.py</span></b></code><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";"><span style="white-space-collapse: preserve;"> and add the following code:</span><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">from</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
django.http </span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">import</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> HttpResponse<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">def</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> </span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #f22c3d; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">index</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">(<span style="border: solid #E3E3E3 1.0pt; mso-border-alt: solid #E3E3E3 .25pt; padding: 0in;">request</span>):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> </span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">return</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> HttpResponse(</span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #00a67d; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">"Hello, welcome to my Django
web application!"</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">) <o:p></o:p></span></p><p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><br /></span></p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUSvRDwbuavcKAsN7_rLGQDbQ_ZgjyLTreTDV4vN1_IjfinfNHY_zt4G5eKbHLG4zaX6N57_mHcmWjwkmlS4xlWyC9t0cHnjoTsOJwnTlvQEbUMgtb4OdcEMDuLVy5pIZgJtM1VkknJt6hoLV5Iq56SPJl2hZVI1e0XRCCZyBpYsokWRv6ljun6Ry1J7KV/s926/myproject.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="232" data-original-width="926" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUSvRDwbuavcKAsN7_rLGQDbQ_ZgjyLTreTDV4vN1_IjfinfNHY_zt4G5eKbHLG4zaX6N57_mHcmWjwkmlS4xlWyC9t0cHnjoTsOJwnTlvQEbUMgtb4OdcEMDuLVy5pIZgJtM1VkknJt6hoLV5Iq56SPJl2hZVI1e0XRCCZyBpYsokWRv6ljun6Ry1J7KV/w640-h160/myproject.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;">Views are here:</span></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEnu0SWHjfYxzQUQOIJyehb4_PzNWYEtAd8Qyago-x3yeZEZ1cm-a-2-TCDnYzovjt_5Bw0kdBcfQVurVVTAnqAn8hvtzojmIpEm7KLpxW8cS0KQ_0ciy1ypO-5aBaY35PT3z98zoVfktpDMuTE-IAPP_sOG3RmZ67uE6QWBgPHifxYagNsPa1MrivAl5z/s918/myapp.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="308" data-original-width="918" height="214" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEnu0SWHjfYxzQUQOIJyehb4_PzNWYEtAd8Qyago-x3yeZEZ1cm-a-2-TCDnYzovjt_5Bw0kdBcfQVurVVTAnqAn8hvtzojmIpEm7KLpxW8cS0KQ_0ciy1ypO-5aBaY35PT3z98zoVfktpDMuTE-IAPP_sOG3RmZ67uE6QWBgPHifxYagNsPa1MrivAl5z/w640-h214/myapp.jpg" width="640" /></a></div><br /><p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI", "sans-serif";">Next, we need to define the URL pattern for this view. Open
the file </span><code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; box-sizing: border-box; white-space-collapse: preserve;"><b><span style="background: white; border: solid #E3E3E3 1.0pt; color: #0d0d0d; font-size: 10.5pt; line-height: 115%; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; padding: 0in;">myproject/urls.py</span></b></code><span style="background: white; color: #0d0d0d; font-family: "Segoe UI", "sans-serif";"><span style="white-space-collapse: preserve;"> and add the following code:</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">from</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
django.urls </span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">import</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> path<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">from</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
myapp </span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #2e95d3; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">import</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> views<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">urlpatterns = [<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
path(</span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #00a67d; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">''</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">,
views.index, name=</span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #00a67d; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">'index'</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">),<o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">] <o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">Now, we have defined the view and URL pattern for our
application. We just need to configure the Django project to use our new
application. Open the file </span><code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; box-sizing: border-box; white-space-collapse: preserve;"><b><span style="background: white; border: solid #E3E3E3 1.0pt; color: #0d0d0d; font-size: 10.5pt; line-height: 115%; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; padding: 0in;">myproject/settings.py</span></b></code><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";"><span style="white-space-collapse: preserve;"> and add </span></span><code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; box-sizing: border-box; white-space-collapse: preserve;"><b><span style="background: white; border: solid #E3E3E3 1.0pt; color: #0d0d0d; font-size: 10.5pt; line-height: 115%; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; padding: 0in;">'myapp',</span></b></code><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";"><span style="white-space-collapse: preserve;"> to the </span></span><code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; box-sizing: border-box; white-space-collapse: preserve;"><b><span style="background: white; border: solid #E3E3E3 1.0pt; color: #0d0d0d; font-size: 10.5pt; line-height: 115%; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; padding: 0in;">INSTALLED_APPS</span></b></code><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";"><span style="white-space-collapse: preserve;"> list:</span><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">INSTALLED_APPS = [<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
...<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">
</span><span style="background: #0D0D0D; border: solid #E3E3E3 1.0pt; color: #00a67d; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; padding: 0in;">'myapp'</span><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">]</span><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">Urls and settings are here:</span></p><p class="MsoNormal"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5LrZwPy9AE1z2rP8PeHmf30fMXNrO0EXwfcwtkZZNj_Lg4FNjdai6MzObC_3rR4pQLY4pJNqyITPSM1uzlyJuhS4IAFGsS-ymbRHJupTCtYakDkWtLqLyAnhozNz2EuFr9VKdvHoAxdCs7VatTZv16mcmgvQqAZSB4fFL1GAjWIAiBXbX0jfRLEfWQ47O/s918/myproject-in-myproject.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="274" data-original-width="918" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5LrZwPy9AE1z2rP8PeHmf30fMXNrO0EXwfcwtkZZNj_Lg4FNjdai6MzObC_3rR4pQLY4pJNqyITPSM1uzlyJuhS4IAFGsS-ymbRHJupTCtYakDkWtLqLyAnhozNz2EuFr9VKdvHoAxdCs7VatTZv16mcmgvQqAZSB4fFL1GAjWIAiBXbX0jfRLEfWQ47O/w640-h192/myproject-in-myproject.jpg" width="640" /></a></div><br /> <p></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">Finally, run the development server using the following
command:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">Run it from POWERSHELL that you had opened in the beginning.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%;">python manage.py runserver</span> <o:p></o:p></p>
<p class="MsoNormal"><span style="background: #0D0D0D; color: white; font-family: Monaco; font-size: 10.5pt; line-height: 115%;"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">Now, if you open a web browser and navigate to </span><code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; box-sizing: border-box; white-space-collapse: preserve;"><b><span style="background: white; border: solid #E3E3E3 1.0pt; color: #0d0d0d; font-size: 10.5pt; line-height: 115%; mso-border-alt: solid #E3E3E3 .25pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; padding: 0in;">http://127.0.0.1:8000/</span></b></code><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";"><span style="white-space-collapse: preserve;">, you should see the greeting message "Hello,
welcome to my Django web application!" displayed on the page.</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="background: white; color: #0d0d0d; font-family: "Segoe UI","sans-serif";">The screen outputs:</span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTrmY72_wMizieoHtXM6ifHiU1VynfjeSGWWsp5ami8WfzRbihh9zVX0u4yPlKz_dblRBNLL42TiPBrQ8ijyDmb40NPdQfP7UpDemalM9iCqKMWMx-McXVu367eirDex7IUAFRE6fmoVisgWWPOQq3y8jGphKHelSWC3GweYsye9CiKYL_So2tLCcsrdHt/s932/Django1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="208" data-original-width="932" height="142" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTrmY72_wMizieoHtXM6ifHiU1VynfjeSGWWsp5ami8WfzRbihh9zVX0u4yPlKz_dblRBNLL42TiPBrQ8ijyDmb40NPdQfP7UpDemalM9iCqKMWMx-McXVu367eirDex7IUAFRE6fmoVisgWWPOQq3y8jGphKHelSWC3GweYsye9CiKYL_So2tLCcsrdHt/w640-h142/Django1.jpg" 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/AVvXsEgDPu5BreGVRQ5CJYgkQxM4VWnj6Vh6M84sQ5IZ6Ap-MJtpiAtm9GIgAeaFL063FMYLitVL_YecW2D8UdFiEfYvMp528ioKMdzJOc5Tz8gadLdTNR082paglLDdmazKlYSsNw9pLk-3gKZqNtfXaJxJcQNmmtcPIYioqX_L1BXzjfu2FvUXbflxRioIbwI2/s666/django2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="640" data-original-width="666" height="616" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDPu5BreGVRQ5CJYgkQxM4VWnj6Vh6M84sQ5IZ6Ap-MJtpiAtm9GIgAeaFL063FMYLitVL_YecW2D8UdFiEfYvMp528ioKMdzJOc5Tz8gadLdTNR082paglLDdmazKlYSsNw9pLk-3gKZqNtfXaJxJcQNmmtcPIYioqX_L1BXzjfu2FvUXbflxRioIbwI2/w640-h616/django2.jpg" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-34789668842802025892024-03-18T07:31:00.000-07:002024-03-18T07:31:16.241-07:00Simplest Python interaction app for neural networks<p> <span style="background-color: white; font-family: "Segoe UI", "sans-serif";">Making artificial neural networks
is not enough by itself. You have to package them in a standalone application
like Qt or a Web application. Here is the simplest (working) Python Qt app:</span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"> </span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"># -*- coding: utf-8 -*-<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">"""<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">Created on Mon Mar 18 16:08:42 2024<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">@author: ars<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">"""<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">import sys<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">from PyQt5.QtWidgets import
QApplication, QWidget, QPushButton, QMessageBox<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">class MyApp(QWidget):<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">def<span class="white-space-pre"> </span><strong>init</strong>(self):<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">super().__init__()<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">self.initUI()<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">def initUI(self):<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">self.setGeometry(100, 100, 300,
200)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">self.setWindowTitle('Simple App')<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">self.button = QPushButton('Click
me', self)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">self.button.setGeometry(100, 100,
100, 50)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">self.button.clicked.connect(self.showMessageBox)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><a href="http://self.show/" target="_self"><span style="font-family: "Segoe UI","sans-serif";">self.show</span></a><span style="font-family: "Segoe UI","sans-serif";">()<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">def showMessageBox(self):<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">QMessageBox.information(self,
'Message', 'Button clicked!')<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">if<span class="white-space-pre"> </span><strong>name</strong><span class="white-space-pre"> </span>== '__main__':<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">app = QApplication(sys.argv)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">ex = MyApp()<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">sys.exit(app.exec_())<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-65963495570274357662024-02-28T05:02:00.000-08:002024-02-28T05:44:35.704-08:00Simple Two Parallel Inputs and One Output Transformer Example<p> <b><span style="color: red; font-size: 14pt; line-height: 115%;">SIMPLE TWO PARALLEL INPUTS AND ONE OUTPUT TRANSFORMER EXAMPLE</span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">This is a
simple example for a transformer taking 2 input arrays and producing a single
output array.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">I will come
with further examples of using multiple layers and complex structures with
transformer approach. Please note that
if one of the inputs were a picture and the other a text the transformer would
recognise that what it sees a CAT... <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">The program
takes two number arrays of length 5. It
calculates the average of two numbers of the same sequence in these two
arrays. This is a working example.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># -*-
coding: utf-8 -*-<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">"""<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Created on
Wed Feb 28 15:16:28 2024<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">@author: ars<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">"""<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">import
tensorflow as tf<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">from
tensorflow.keras import layers, Model<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Define the
transformer layer<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">class
TransformerLayer(layers.Layer):<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> def __init__(self, d_model, num_heads, dff,
rate=0.1):<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> super(TransformerLayer,
self).__init__()<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> self.mha = layers.MultiHeadAttention(num_heads=num_heads,
key_dim=d_model)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> self.ffn = tf.keras.Sequential([<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> layers.Dense(dff,
activation='relu'),<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> layers.Dense(d_model)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> ])<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> self.layernorm1 =
layers.LayerNormalization(epsilon=1e-6)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> self.layernorm2 =
layers.LayerNormalization(epsilon=1e-6)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> self.dropout1 = layers.Dropout(rate)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> self.dropout2 = layers.Dropout(rate)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> def call(self, inputs, training=True):<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> attn_output = self.mha(inputs, inputs)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> attn_output =
self.dropout1(attn_output, training=training)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> out1 = self.layernorm1(inputs +
attn_output)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> ffn_output = self.ffn(out1)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> ffn_output = self.dropout2(ffn_output,
training=training)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> out2 = self.layernorm2(out1 + ffn_output)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> return out2<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Define the
input shape<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">input_shape
= (5,)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Define the
inputs<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">input1 =
layers.Input(shape=input_shape, name='input1')<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">input2 =
layers.Input(shape=input_shape, name='input2')<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">#
Concatenate the inputs<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">concatenated
= layers.Concatenate(axis=1)([input1, input2])<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Reshape
for transformer input<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">reshape =
layers.Reshape((2, 5))(concatenated)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">#
Transformer layer<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">transformer_layer
= TransformerLayer(d_model=5, num_heads=2, dff=32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Apply
transformer layer<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">transformed_output
= transformer_layer(reshape)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Global
average pooling<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">average_output
= layers.GlobalAveragePooling1D()(transformed_output)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Output
layer<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">output =
layers.Dense(5, activation='linear')(average_output)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Build the
model<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">model =
Model(inputs=[input1, input2], outputs=output)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Compile
the model<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">model.compile(optimizer='adam',
loss='mean_squared_error', metrics=['mae'])<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Print the
model summary<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">model.summary()<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">#%%#---------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">import numpy
as np<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Generate
some random test data<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">num_samples
= 1000<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">input1_test
= np.random.rand(num_samples, 5)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">input2_test
= np.random.rand(num_samples, 5)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Calculate
the average manually for comparison<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">average_manual
= (input1_test + input2_test) / 2.0<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Check the
shape of the test data<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">print("Shape
of input1_test:", input1_test.shape)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">print("Shape
of input2_test:", input2_test.shape)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Test the
model<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">predictions
= model.predict([input1_test, input2_test])<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"># Compare
the predictions with the manual calculation<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">for i in
range(5):<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> print("\nSample", i+1, " -
input1:", input1_test[i])<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> print("Sample", i+1, " -
input2:", input2_test[i]) <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"> print("Sample", i+1, " -
Manual Average:", average_manual[i], " - Predicted Average:",
predictions[i])<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p>MODEL:---------------------------------------------------------------------</p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Model:
"model"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">__________________________________________________________________________________________________<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> Layer (type) Output Shape Param # Connected to <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">==================================================================================================<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input1 (InputLayer) [(None, 5)] 0 []
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input2 (InputLayer) [(None, 5)] 0 []
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> concatenate_1 (Concatenate (None, 10) 0 ['input1[0][0]', <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> )
'input2[0][0]'] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> reshape_1 (Reshape) (None, 2, 5) 0 ['concatenate_1[0][0]'] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> transformer_layer_1 (Trans (None, 2, 5) 612 ['reshape_1[0][0]'] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> formerLayer)
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> global_average_pooling1d ( (None, 5) 0 ['transformer_layer_1[0][0]'] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> GlobalAveragePooling1D)
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dense_4 (Dense) (None, 5) 30 ['global_average_pooling1d[0][<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
0]'] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">OUTPUT:--------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">runcell(1,
'C:/Users/ars/ARStensorflow/0parallelARS/untitled0.py')<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Shape of
input1_test: (1000, 5)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Shape of
input2_test: (1000, 5)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">32/32
[==============================] - 0s 3ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
1 - input1: [0.40338464 0.4324481 0.20288709 0.85402018 0.69681939]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
1 - input2: [0.92298319 0.39169773
0.47804982 0.80640389 0.96490146]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
1 - Manual Average: [0.66318391
0.41207291 0.34046846 0.83021203 0.83086043]
- Predicted Average: [ 0.41462776
0.16984153 1.310897 1.2504835
-0.22809528]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
2 - input1: [0.7499501 0.1342272
0.09384698 0.32732734 0.6872341 ]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
2 - input2: [0.76973532 0.10832048
0.32817306 0.60530674 0.61595368]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
2 - Manual Average: [0.75984271
0.12127384 0.21101002 0.46631704 0.65159389]
- Predicted Average: [-0.4052685
0.01396421 -0.05984974 1.1452911 -0.23754917]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
3 - input1: [0.3095081 0.25686936 0.83059622 0.20532096 0.80553001]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
3 - input2: [0.66867723 0.38651418
0.36205749 0.91205604 0.13740754]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
3 - Manual Average: [0.48909267
0.32169177 0.59632685 0.5586885
0.47146877] - Predicted Average:
[-0.49286604 -0.0415334 -0.49873334 0.53398705 -0.18983857]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
4 - input1: [0.363748 0.96901881 0.760858 0.31562726 0.50555152]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
4 - input2: [0.55109577 0.87754127
0.87178709 0.42192351 0.3426839 ]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
4 - Manual Average: [0.45742188
0.92328004 0.81632255 0.36877539 0.42411771]
- Predicted Average: [-0.89761406
0.03873652 -1.0142024 1.4196234 0.16065012]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
5 - input1: [0.15684707 0.07559663
0.26578657 0.00073441 0.31646286]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
5 - input2: [0.17205819 0.57338043
0.40403394 0.49935905 0.76232375]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
5 - Manual Average: [0.16445263
0.32448853 0.33491026 0.25004673 0.5393933 ]
- Predicted Average: [0.07035738 0.19064039 0.74532485 1.6838341 0.1143308 ]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">runcell(1,
'C:/Users/ars/ARStensorflow/0parallelARS/untitled0.py')<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Shape of
input1_test: (1000, 5)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Shape of
input2_test: (1000, 5)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">32/32
[==============================] - 0s 3ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
1 - input1: [0.15694803 0.21293792
0.47923616 0.98860532 0.07281257]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
1 - input2: [0.92906837 0.68171534
0.74526118 0.40535621 0.77818246]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
1 - Manual Average: [0.5430082 0.44732663 0.61224867 0.69698076
0.42549751] - Predicted Average:
[-0.6867658 -0.46808803 -0.12430111 0.6539723
-0.44549745]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
2 - input1: [0.28995958 0.38700105
0.7171286 0.8887408 0.10529674]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
2 - input2: [0.26600798 0.42171587
0.38329856 0.51847964 0.07816427]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
2 - Manual Average: [0.27798378
0.40435846 0.55021358 0.70361022 0.0917305 ]
- Predicted Average: [-1.2057661
-0.6692148 -1.1835346 -0.05061923 -0.49671552]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
3 - input1: [0.31312179 0.59934665
0.64874245 0.26271201 0.52528184]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
3 - input2: [0.28762358 0.36924366
0.05406523 0.9903467 0.01666271]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
3 - Manual Average: [0.30037268
0.48429516 0.35140384 0.62652935 0.27097228]
- Predicted Average: [ 0.04163997 -0.26772195 0.6635431
0.24431774 -0.24538673]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
4 - input1: [0.26770316 0.22319183
0.72713793 0.55752506 0.39540953]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
4 - input2: [0.53671129 0.15183273
0.55340938 0.0380593 0.95026388]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
4 - Manual Average: [0.40220723
0.18751228 0.64027366 0.29779218 0.6728367 ]
- Predicted Average: [-1.1873685
-0.5455142 -0.77665997 1.1318963
-0.22853746]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
5 - input1: [0.15905445 0.74677288
0.99688255 0.38000617 0.08582965]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
5 - input2: [0.09005614 0.42813253
0.72824425 0.28000251 0.36697629]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Sample
5 - Manual Average: [0.1245553 0.5874527
0.8625634 0.33000434
0.22640297] - Predicted Average:
[-1.498805 -0.7617358 -1.405476
0.60692716 -0.08873218]<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;">Note: This transformer needs tuning or structural adjusting.</p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-63006139615203285642024-02-14T07:09:00.000-08:002024-02-14T07:09:35.860-08:00 How to use a neural network model from an other program<p> <b style="text-align: center;"><span style="color: red; font-family: "Segoe UI","sans-serif"; font-size: 16.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; mso-font-kerning: 18.0pt;">How
to use a neural network model from an other program</span></b></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"> </span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"># simple_sequential_</span><a href="http://network.py/" target="_self"><span style="font-family: "Segoe UI","sans-serif";">network.py</span></a><span style="font-family: "Segoe UI","sans-serif";"><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">from keras.models import Sequential<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">from keras.layers import Dense<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">def
create_sequential_model(input_dim):<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">model = Sequential()<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">model.add(Dense(10,
input_dim=input_dim, activation='relu')) # Example layer, adjust as needed<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">model.add(Dense(1,
activation='sigmoid')) # Output layer, adjust as needed<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">model.compile(loss='binary_crossentropy',
optimizer='adam', metrics=['accuracy'])<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">return model<span class="white-space-pre"> </span><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">from an other program:
----------------------------------<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"> </span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"># make_</span><a href="http://predictions.py/" target="_self"><span style="font-family: "Segoe UI","sans-serif";">predictions.py</span></a><span style="font-family: "Segoe UI","sans-serif";"><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">import numpy as np<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">from simple_sequential_network
import create_sequential_model<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"># Load the model<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">input_dim = 5 # Example input
dimension, should match the input dimension of the model<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">model =
create_sequential_model(input_dim)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"># Load sample data for prediction<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">X_new = np.random.rand(10,
input_dim) # Example: 10 new samples, each with input_dim features<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"># Make predictions<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">predictions = model.predict(X_new)<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">print("Predictions:")<o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">print(predictions)<span class="white-space-pre"> </span><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">Bu çok küçük bir adım... Daha
büyükleri için:<span class="white-space-pre"> </span><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><a href="https://openai.com/research/techniques-for-training-large-neural-networks" target="_self"><span style="font-family: "Segoe UI","sans-serif";">https://openai.com/research/techniques-for-training-large-neural-networks</span></a><span style="font-family: "Segoe UI","sans-serif";"><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><a href="https://medium.com/@TheHaseebHassan/techniques-to-train-large-neural-networks-e315f1edddd4" target="_self"><span style="font-family: "Segoe UI","sans-serif";">https://medium.com/@TheHaseebHassan/techniques-to-train-large-neural-networks-e315f1edddd4</span></a><span style="font-family: "Segoe UI","sans-serif";"><o:p></o:p></span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";"> </span></p>
<p class="ember-view" style="background: white; margin-bottom: .0001pt; margin: 0in;"><span style="font-family: "Segoe UI","sans-serif";">Kolaylıklar...<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-11113416247613061902024-02-14T07:08:00.000-08:002024-02-14T07:08:57.202-08:00simple parallelism in neural networks<p> <b style="text-align: center;"><span style="color: red; font-size: 20.0pt; line-height: 115%;">simple parallelism in neural networks</span></b></p><p><b style="text-align: center;"><span style="color: red; font-size: 20.0pt; line-height: 115%;"><br /></span></b></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">A simple network
with 2 parallel inputs compares two numbers and decides which one is bigger. Inputs from 2 input layers are concatenated
and then passed through a final dense layer.
I have tested the network without this final layer and saw that this
final layer increases accuracy.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Without final
layer:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Test Loss:
0.10025522857904434, Test Accuracy: 0.984000027179718<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">With final
layer:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Test Loss:
0.08202387392520905, Test Accuracy: 0.9919999837875366<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># -*-
coding: utf-8 -*-<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">"""<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Created on
Wed Feb 14 17:37:39 2024<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">@author: ars<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">"""<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">from
keras.layers import Input, Dense, concatenate<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">from
keras.models import Model<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Define
input shapes<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_shape1
= (1,) # Shape for the first input<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_shape2
= (1,) # Shape for the second input<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Define
input layers<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_layer1
= Input(shape=input_shape1, name='input1')<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_layer2
= Input(shape=input_shape2, name='input2')<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Define
first parallel layer<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">dense_layer1
= Dense(64, activation='relu')(input_layer1)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Define
second parallel layer<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">dense_layer2
= Dense(64, activation='relu')(input_layer2)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">#
Concatenate the outputs of the two parallel layers<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">concatenated_layers
= concatenate([dense_layer1, dense_layer2])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Add an
extra dense layer<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">extra_dense_layer
= Dense(32, activation='relu')(concatenated_layers)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Output
layer<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">output_layer
= Dense(1, activation='sigmoid', name='output')(extra_dense_layer)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Create the
model<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model =
Model(inputs=[input_layer1, input_layer2], outputs=output_layer)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Compile
the model<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model.compile(optimizer='adam',
loss='binary_crossentropy', metrics=['accuracy'])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Print
model summary<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model.summary()<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">#%%<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">import numpy
as np<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Generate
training data<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">num_samples
= 1000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">X1_train =
np.random.rand(num_samples, 1) * 100 #
Random numbers between 0 and 100<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">X2_train =
np.random.rand(num_samples, 1) * 100 #
Random numbers between 0 and 100<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train =
(X1_train > X2_train).astype(int) # 1
if first number is greater, 0 otherwise<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Train the
model<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model.fit([X1_train,
X2_train], y_train, epochs=10, batch_size=32, validation_split=0.2)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">#%%<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Make
predictions for numbers 12 and 34<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_data1
= np.array([[12.0]])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_data2
= np.array([[34.0]])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">predictions_12
= model.predict([input_data1, input_data2])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">print("Prediction
for 12 and 34:", predictions_12)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Make
predictions for numbers 34 and 12 (swapping the order)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_data1_swapped
= np.array([[34.0]])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_data2_swapped
= np.array([[12.0]])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">predictions_34
= model.predict([input_data1_swapped, input_data2_swapped])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">print("Prediction
for 34 and 12:", predictions_34)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">#%%<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Generate
test data<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">num_test_samples
= 500<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">X1_test =
np.random.rand(num_test_samples, 1) * 100
# Random numbers between 0 and 100<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">X2_test =
np.random.rand(num_test_samples, 1) * 100
# Random numbers between 0 and 100<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_test =
(X1_test > X2_test).astype(int) # 1
if first number is greater, 0 otherwise<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"># Evaluate
the model on test data<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">loss,
accuracy = model.evaluate([X1_test, X2_test], y_test)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">print(f"Test
Loss: {loss}, Test Accuracy: {accuracy}")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">runfile('C:/Users/ars/ARStensorflow/0parallelARS/parallelLayersAddFinalLayer.py',
wdir='C:/Users/ars/ARStensorflow/0parallelARS')<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Model:
"model_3"<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">__________________________________________________________________________________________________<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> Layer (type) Output Shape Param # Connected to <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">==================================================================================================<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input1 (InputLayer) [(None, 1)] 0 []
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input2 (InputLayer) [(None, 1)] 0 []
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dense_8 (Dense) (None, 64) 128 ['input1[0][0]'] <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dense_9 (Dense) (None, 64) 128 ['input2[0][0]'] <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> concatenate_3 (Concatenate (None, 128) 0 ['dense_8[0][0]', <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> )
'dense_9[0][0]'] <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dense_10 (Dense) (None, 32) 4128 ['concatenate_3[0][0]'] <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> output (Dense)
(None, 1) 33 ['dense_10[0][0]'] <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">==================================================================================================<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Total
params: 4417 (17.25 KB)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Trainable
params: 4417 (17.25 KB)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Non-trainable
params: 0 (0.00 Byte)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">__________________________________________________________________________________________________<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 1/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 2s 14ms/step - loss: 0.6836 - accuracy:
0.8263 - val_loss: 0.1272 - val_accuracy: 0.9800<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 2/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.1112 - accuracy:
0.9625 - val_loss: 0.0992 - val_accuracy: 0.9850<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 3/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0861 - accuracy:
0.9850 - val_loss: 0.0839 - val_accuracy: 0.9800<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 4/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0717 - accuracy:
0.9900 - val_loss: 0.0709 - val_accuracy: 1.0000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 5/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0671 - accuracy:
0.9862 - val_loss: 0.0758 - val_accuracy: 0.9700<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 6/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 5ms/step - loss: 0.0609 - accuracy:
0.9850 - val_loss: 0.0604 - val_accuracy: 0.9950<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 7/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0566 - accuracy:
0.9950 - val_loss: 0.0572 - val_accuracy: 0.9850<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 8/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0536 - accuracy:
0.9912 - val_loss: 0.0528 - val_accuracy: 1.0000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 9/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0553 - accuracy:
0.9862 - val_loss: 0.0504 - val_accuracy: 0.9950<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 10/10<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">25/25
[==============================] - 0s 4ms/step - loss: 0.0485 - accuracy:
0.9887 - val_loss: 0.0497 - val_accuracy: 0.9850<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 105ms/step<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Prediction
for 12 and 34: [[0.00312641]]<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 34ms/step<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Prediction
for 34 and 12: [[0.99910635]]<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">16/16
[==============================] - 0s 2ms/step - loss: 0.0456 - accuracy:
0.9960<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Test Loss:
0.045580483973026276, Test Accuracy: 0.9959999918937683<o:p></o:p></p><p>
</p><p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p><p align="center" class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;"><b><span style="color: red; font-size: 20.0pt; line-height: 115%;"><o:p></o:p></span></b></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-24239279935917445422024-01-22T04:12:00.000-08:002024-01-22T04:14:01.666-08:00A simple Turkish speaking chatbot example (and working)<p style="text-align: center;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCx-xjgyfk_g_dOwn-UZeF9GtRlsKvjHoXWg0v7hLG1Fb4q8sYnSjbSLjhVvUVzNequn5zhudFZ8GWoaA0goMDvPzOiEwixkn5bTavvESr5bMQ2iRmVe9lqWdT0sUeokxv2SL2QjOF57U30BgCZDa2Dd1bZjD8dlObCzB0U5UOuBw3nWoIONiGwcIht4zj/s305/111.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="248" data-original-width="305" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCx-xjgyfk_g_dOwn-UZeF9GtRlsKvjHoXWg0v7hLG1Fb4q8sYnSjbSLjhVvUVzNequn5zhudFZ8GWoaA0goMDvPzOiEwixkn5bTavvESr5bMQ2iRmVe9lqWdT0sUeokxv2SL2QjOF57U30BgCZDa2Dd1bZjD8dlObCzB0U5UOuBw3nWoIONiGwcIht4zj/s1600/111.jpg" width="305" /></a></div><br /> <p></p><p><span color="rgba(0, 0, 0, 0.9)" face="-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif" style="background-color: white; font-size: var(--font-size-large);">Not: Bazı şirketler telefonla arayan müşterilere otomatik olarak ne istediklerini sorup ona göre yönlendiriyorlar. Aslında bir kaç saatlik basit bir iş. İnternetteki bilgileri kullanarak kolayca yaptım bunu.</span><span class="white-space-pre" color="rgba(0, 0, 0, 0.9)" face="-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif" style="border: var(--artdeco-reset-base-border-zero); box-sizing: inherit; font-size: var(--artdeco-reset-base-font-size-hundred-percent); margin: var(--artdeco-reset-base-margin-zero); outline: var(--artdeco-reset-base-outline-zero); padding: var(--artdeco-reset-base-padding-zero); vertical-align: var(--artdeco-reset-base-vertical-align-baseline); white-space: pre;"> </span></p><p class="MsoNormal" style="margin-bottom: 0in;"># -*-
coding: utf-8 -*-<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">"""<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Created on
Fri Jan 19 15:43:41 2024<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">pip install
speechRecognition<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">pip install
gTTS <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">pip install
pyaudio<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">@author: ars<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">"""<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">import
speech_recognition as sr<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">from gtts
import gTTS<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">import os<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">import
datetime<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">import numpy
as np<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">import time<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"># Beginning
of the AI<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">class
ChatBot():<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> def __init__(self, name):<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> print("----- starting up",
name, "-----")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> self.name = name<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> self.text = "" # Initialize text attribute<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> def speech_to_text(self):<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> recognizer = sr.Recognizer()<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> with sr.Microphone() as mic:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> print("dinliyorum...")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> audio = recognizer.listen(mic)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> try:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> self.text =
recognizer.recognize_google(audio, language="tr-TR")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> print("me --> ",
self.text)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> if "dur" in
self.text.lower(): return False<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> except:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> print("me --> ERROR")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> def wake_up(self, text):<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> return True if self.name in
text.lower() else False<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> @staticmethod<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> def text_to_speech(text):<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> print("AI --> ", text)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> speaker = gTTS(text=text,
lang="tr", slow=False)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> speaker.save("res.mp3")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> mp3_path = os.path.join(os.getcwd(),
"res.mp3")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> print(mp3_path)<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> statbuf = os.stat("res.mp3")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> mbytes = statbuf.st_size / 1024<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> duration = mbytes / 200<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> os.system("start
res.mp3") #if you have a
macbook->afplay or for windows use->start<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> #os.remove("res.mp3")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> time.sleep(int(50*duration))<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> os.remove("res.mp3")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> @staticmethod<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> def action_time():<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> return
datetime.datetime.now().time().strftime('%H:%M')<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> #and run the script after adding the above
function to the AI class<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"># Execute
the AI<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">if __name__
== "__main__":<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ai = ChatBot(name="başla") <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"># Execute
the AI<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">if __name__
== "__main__":<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ai = ChatBot(name="başla")<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> while True:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> if ai.speech_to_text() == False: <o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> break<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> # Default response<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> res = "Anlayamadım. Tekrarlar
mısınız?"<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ## wake up<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> if ai.wake_up(ai.text) is True:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> res = "Merhaba ben suni zeka,
sizin için ne yapabilirim?"<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ai.text = "xxx"<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ## do any action<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> elif "saat" in ai.text:<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> res = ai.action_time()<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ## respond politely<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> elif any(i in ai.text for i in
["teşekkür","sağolun"]):<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> res = np.random.choice(<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">
["estağfurullah!","her zaman!",<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> "sorun
değil!","güzel!",<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> "İhtiyacınız olursa ben
buradayım!","önemli değil!"])<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> ai.text_to_speech(res)<o:p></o:p></p><p class="ember-view reader-content-blocks__paragraph" id="ember522" style="--artdeco-reset-typography_getfontsize: 1.6rem; --artdeco-reset-typography_getlineheight: 1.5; background-color: white; border: var(--artdeco-reset-base-border-zero); box-sizing: inherit; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: var(--font-size-large); line-height: 1.75; margin: 1.6rem 0px; padding: var(--artdeco-reset-base-padding-zero); pointer-events: all; vertical-align: var(--artdeco-reset-base-vertical-align-baseline);">
</p><p class="MsoNormal" style="margin-bottom: 0in;"> <o:p></o:p></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-9614643311134469542024-01-14T02:04:00.000-08:002024-01-14T02:04:19.021-08:00TRANSFORMER IMPLEMENTATION RESULTS OF A NUMBER SEQUENCER<p>Results of Number sequencer implementation using transformer algorithm: %success</p><p>X random numbers between 1 - 12 with random length between 1 and X. </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFPAeYs0rdMHvGTN6MQ7AiFqeH7rVEhpgCOW04a-xa3nZ8tbwrwQE5AIrAphGgAQnTx4hyTl85AdrXsInj3yUcTr7cW16W2_JcMBL1rJgGQ4OBxzYSJFE-d7mlnrO-3Ex1mzDoSX_I4BUtdevdocVSb3_8GggvkIZPhyphenhyphenb8A4ZM3vfeteUBl7EN_J80bXVi/s759/key_dim%2064ff_dim%20256%20vocabsize_en%2015%20num_heads%208.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="759" data-original-width="536" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFPAeYs0rdMHvGTN6MQ7AiFqeH7rVEhpgCOW04a-xa3nZ8tbwrwQE5AIrAphGgAQnTx4hyTl85AdrXsInj3yUcTr7cW16W2_JcMBL1rJgGQ4OBxzYSJFE-d7mlnrO-3Ex1mzDoSX_I4BUtdevdocVSb3_8GggvkIZPhyphenhyphenb8A4ZM3vfeteUBl7EN_J80bXVi/w453-h640/key_dim%2064ff_dim%20256%20vocabsize_en%2015%20num_heads%208.png" width="453" /></a></div><br /><p><br /></p><p>Epoch 90/100</p><p>55/55 [==============================] - 5s 95ms/step - loss: 0.0621 - masked_accuracy: 0.9817 - val_loss: 0.0733 - val_masked_accuracy: 0.9769</p><p>Epoch 91/100</p><p>55/55 [==============================] - 5s 100ms/step - loss: 0.0667 - masked_accuracy: 0.9799 - val_loss: 0.0209 - val_masked_accuracy: 0.9923</p><p>Epoch 92/100</p><p>55/55 [==============================] - 6s 118ms/step - loss: 0.0817 - masked_accuracy: 0.9763 - val_loss: 0.0309 - val_masked_accuracy: 0.9908</p><p>Epoch 93/100</p><p>55/55 [==============================] - 5s 96ms/step - loss: 0.0706 - masked_accuracy: 0.9782 - val_loss: 0.0502 - val_masked_accuracy: 0.9843</p><p>Epoch 94/100</p><p>55/55 [==============================] - 5s 98ms/step - loss: 0.0688 - masked_accuracy: 0.9805 - val_loss: 0.0436 - val_masked_accuracy: 0.9868</p><p>Epoch 95/100</p><p>55/55 [==============================] - 6s 107ms/step - loss: 0.0840 - masked_accuracy: 0.9746 - val_loss: 0.0388 - val_masked_accuracy: 0.9881</p><p>Epoch 96/100</p><p>55/55 [==============================] - 6s 102ms/step - loss: 0.0503 - masked_accuracy: 0.9853 - val_loss: 0.0591 - val_masked_accuracy: 0.9803</p><p>Epoch 97/100</p><p>55/55 [==============================] - 6s 110ms/step - loss: 0.0399 - masked_accuracy: 0.9875 - val_loss: 0.0563 - val_masked_accuracy: 0.9826</p><p>Epoch 98/100</p><p>55/55 [==============================] - 5s 98ms/step - loss: 0.0865 - masked_accuracy: 0.9774 - val_loss: 0.0444 - val_masked_accuracy: 0.9858</p><p>Epoch 99/100</p><p>55/55 [==============================] - 6s 115ms/step - loss: 0.1183 - masked_accuracy: 0.9689 - val_loss: 0.0819 - val_masked_accuracy: 0.9749</p><p>Epoch 100/100</p><p>55/55 [==============================] - 5s 96ms/step - loss: 0.0709 - masked_accuracy: 0.9809 - val_loss: 0.0347 - val_masked_accuracy: 0.9905</p><p>Test 0:</p><p>3 4</p><p>== [start] 3 4 [end]</p><p>-> [start] 3 4 [end]</p><p><br /></p><p>Test 1:</p><p>2 7 2 4 5 12 1</p><p>== [start] 1 2 2 4 5 7 12 [end]</p><p>-> [start] 1 2 2 4 5 7 12 [end]</p><p><br /></p><p>Test 2:</p><p>1 3 1 9 3 6</p><p>== [start] 1 1 3 3 6 9 [end]</p><p>-> [start] 1 1 3 3 6 9 [end]</p><p><br /></p><p>Test 3:</p><p>1</p><p>== [start] 1 [end]</p><p>-> [start] 1 [end]</p><p><br /></p><p>Test 4:</p><p>12 8 11 8 3 2</p><p>== [start] 2 3 8 8 11 12 [end]</p><p>-> [start] 2 3 8 8 11 12 [end]</p><p><br /></p><p>Test 5:</p><p>8 3 1</p><p>== [start] 1 3 8 [end]</p><p>-> [start] 1 3 8 [end]</p><p><br /></p><p>Test 6:</p><p>8 9 4 7 5 4 2 7</p><p>== [start] 2 4 4 5 7 7 8 9 [end]</p><p>-> [start] 2 4 4 5 7 7 8 9</p><p><br /></p><p>Test 7:</p><p>5</p><p>== [start] 5 [end]</p><p>-> [start] 5 [end]</p><p><br /></p><p>Test 8:</p><p>2 8 4</p><p>== [start] 2 4 8 [end]</p><p>-> [start] 2 4 8 [end]</p><p><br /></p><p>Test 9:</p><p>3</p><p>== [start] 3 [end]</p><p>-> [start] 3 [end]</p><p><br /></p><p>Test 10:</p><p>7 8 11 1</p><p>== [start] 1 7 8 11 [end]</p><p>-> [start] 1 7 8 11 [end]</p><p><br /></p><p>Test 11:</p><p>6 4</p><p>== [start] 4 6 [end]</p><p>-> [start] 4 6 [end]</p><p><br /></p><p>Test 12:</p><p>3 12 3 3 3 8 10</p><p>== [start] 3 3 3 3 8 10 12 [end]</p><p>-> [start] 3 3 3 3 8 10 12 [end]</p><p><br /></p><p>Test 13:</p><p>1 4 4 11 6 7 4 5</p><p>== [start] 1 4 4 4 5 6 7 11 [end]</p><p>-> [start] 1 4 4 5 5 6 7 11</p><p><br /></p><p>Test 14:</p><p>1 3 8</p><p>== [start] 1 3 8 [end]</p><p>-> [start] 1 3 8 [end]</p><p><br /></p><p>Test 15:</p><p>4 9 7 3 2</p><p>== [start] 2 3 4 7 9 [end]</p><p>-> [start] 2 3 4 7 9 [end]</p><p><br /></p><p>Test 16:</p><p>5 2 11</p><p>== [start] 2 5 11 [end]</p><p>-> [start] 2 5 11 [end]</p><p><br /></p><p>Test 17:</p><p>4 3 9</p><p>== [start] 3 4 9 [end]</p><p>-> [start] 3 4 9 [end]</p><p><br /></p><p>Test 18:</p><p>3 2</p><p>== [start] 2 3 [end]</p><p>-> [start] 2 3 [end]</p><p><br /></p><p>Test 19:</p><p>10 9</p><p>== [start] 9 10 [end]</p><p>-> [start] 9 10 [end]</p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-85123141237514586192023-08-27T08:19:00.000-07:002023-08-27T08:19:14.763-07:00Airline Sentiment Analysis with a Transformer Artificial Neural Network<p> <b style="text-align: center;"><span style="color: red; font-size: 14.0pt; line-height: 115%;">Airline Sentiment Analysis with a Transformer Artificial Neural
Network</span></b></p>
<p align="center" class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;"><i><span style="color: #558ed5; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #558ED5; mso-style-textfill-fill-colortransforms: "lumm=60000 lumo=40000"; mso-style-textfill-fill-themecolor: text2; mso-themecolor: text2; mso-themetint: 153;">Ali Riza SARAL<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">This is a
report on my project for airline sentiment analysis using a Transformer
artificial NNW.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">I took the
'airline twitter sentiment' data from Data World
(https://data.world/datasets/sentiment). This dataset includes customer comments and
their associated sentiments. There are
14641 comments in this Excel file. There
are fields named: _unit_id, _trusted_judgments, airline_sentiment,
airline_sentiment:confidence, negative reason, negativereason:confidence,
airline, text, tweet_coord. I only needed
the airline_sentiment and text fields from this Excel file.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<h1 style="background: white; margin-top: 0in;"><span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; font-weight: normal; mso-ascii-theme-font: minor-latin; mso-bidi-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">The
implementation of sentiment analysis requires a significant effort to prepare
the input data for learning. It also difficult to come with an appropriate
artificial neural network architecture.
AS a beginning I took the ‘<span style="color: #212529;">Text classification with Transformer’ from Keras site: <a href="https://keras.io/examples/nlp/text_classification_with_transformer/">https://keras.io/examples/nlp/text_classification_with_transformer/</a>
<o:p></o:p></span></span></h1>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">This
transformer example uses IMDB movie reviews as data and classifies them as
positive or negative. Although it is a
good and working example, it does not have a prediction part. The difficulty begins with using the IMDB
database and the preprocessing IMDB does is not well documented.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">To make
predictions you have to take a text and process it the same as the inputs you
use for the learning phase. Convert to
lowercase, remove links, remove all sorts of marks, comma, dot etc. and also
some frequent meaningless words such ‘a’ etc.
And then you have to convert the words to word2vector numbers to be able
to process them in the network. The
problem is you have to do the same word2vector conversion as IMDB in order to
have your network do a healthy conversion.
Otherwise for example the word ‘go’ ends up as 234 where as IMDB assigns
459 to it. This is the reason I decided
to use airline sentiment twitter data from Data World to test Keras’s
transformer architecture.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">I did
preprocessing in a short python function:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">import re<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">def
clean_links(text): <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> #cleaned_text =
re.sub(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
'', text, flags=re.MULTILINE)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> cleaned_text = re.sub(r'http[s]?://\S+',
'', text) # Updated regular expression<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> return cleaned_text<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">def
clean_string(input_str):<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> clean_chars = []<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input_str=clean_links(input_str)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input_str=re.sub(r'http[s]?://\S+|\n', '',
input_str)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> for char in input_str:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> if char.isalnum() or char == "'"
or char.isspace():<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> clean_chars.append(char)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> retVal=''.join(clean_chars)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> clean_links(retVal)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> return retVal<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_string
= "driver's licence"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_string
= "https://t.co/mWpG7grEZP"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_string
= "http://t.co/Y7O0uNxTQP"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_string="http://t.co/4gr39s91Dl‰Û_Ù÷â"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_string="http://t.co/4gr39s91Dl‰Û_Ù÷â"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">input_string="http://t.co/GsB2J3c4gM"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">cleaned_string
= clean_string(input_string)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">print(cleaned_string)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">To convert
the texts to numbers for the learning process I first built a dictionary where
each word has a number assigned to. To
build the dictionary, i wrote a program that goes through the whole data and
extracts each word, cleans them with the above function and saves this data to
a file:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">--------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">virginamerica<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">plus<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">you've<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">added<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">commercials<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">to<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">the<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">experience<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">tacky<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">virginamerica<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">didn't<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">today<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">must<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">mean<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">--------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">There are
253076 words and hence lines in this file including the repetitions. I used<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">a rex
utility tat I had written earlier and removed the dups in this file:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">--------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absolute<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absolutely<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absorb<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absorber<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absoulutely<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absurd<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absurdity<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absurdly<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abt<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abundance<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abuse<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abused<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abysmal<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">ac<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-----------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">There are
13786 words hence lines in this file.
This is the dictionary size, the number of words in the dictionary.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The next
step is to preprocess the inputs to the learning phase. This phase extracts the airline_sentiment
values and preprocesses the text values.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">--------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1!positive&
virginamerica plus you've added commercials to the experience tacky<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">2!neutral&
virginamerica i didn't today must mean i need to take another trip<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">3!negative&
virginamerica it's really aggressive to blast obnoxious entertainment in your
guests' faces amp they have little recourse<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">4!negative&
virginamerica and it's a really big bad thing about it<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">5!negative&
virginamerica seriously would pay 30 a flight for seats that didn't have this
playing it's really the only bad thing about flying va<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">6!positive&UnicodeEncodeError<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">7!neutral&
virginamerica really missed a prime opportunity for men without hats parody
there <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">8!positive&
virginamerica well i didn'tûbut now i do d<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">9!positive&
virginamerica it was amazing and arrived an hour early you're too good to me<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">--------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The program
handles if there is a unicode error in the text. Later on the unicode error lines will not be
included into network data.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The next
program creates a word2vec model for dictionary<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">------------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model.build_vocab(initial_sentences)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">and updates
it for each word in the preprocess output of the dictionary, 13800 words<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">saves the
model<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model.save("word2vec_dict_model.model")<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">model.wv.save_word2vec_format("saW2Vdict_vectors.txt",
binary=False)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">------------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">aboout
0.9614743<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abounds
0.49820578<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">about
0.92331433<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">above
-0.8157917<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abq
0.44957983<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">abroad
-0.4137076<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absolute
0.08245361<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absolutely
0.849862<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absorb
-0.44621766<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">absorber
0.45175004<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The next
step does the same for each sentence in the data and creates x_train y_train
data. Here x_train has the text and
y_train has the sentiment. This program
converts all the sentences word by word to numbers and ‘positive’ sentiments to
1, ‘negative’ sentiments to 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">0?
southwestair i continue to be amazed by the amazing customer service thank you
swa![[12252], [677], [18600], [13555], [6673], [7008], [1069], [1150], [9228],
[4573], [17659], [17086], [13689], [2772]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1?
americanair golfwithwoody don't buy it woody they're making it much worse with
understaffing rudeness and prerookie mistakes![[14348], [3087], [10883], [196],
[13835], [16713], [4748], [6870], [13835], [18504], [17594], [12636], [7400],
[16721], [3502], [10051], [13862]]&0<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">2? usairways
thanks to betty working gate at ilm and lovely gate agents here in clt helping
me get home 2 phx tonight instead of tomorrow![[9362], [17243], [13555],
[3706], [16524], [8672], [18355], [17395], [3502], [12246], [8672], [14530],
[7500], [17457], [16153], [6352], [15003], [16996], [13628], [6159], [2349],
[2897], [18895], [6965]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">3?
southwestair i'll stick with flying for free any where that southwest goes my
son works for this wonderful company and moms fly free![[12252], [10557],
[2938], [12636], [6970], [4161], [6466], [3275], [11195], [17114], [8426],
[7158], [17815], [4710], [3650], [4161], [4333], [4784], [15239], [3502],
[16000], [11957], [6466]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">4?
southwestair is there a way to know who checked my bag on the curb she was
awesome and want to be sure she gets a high five![[12252], [14324], [2347],
[3685], [13555], [12020], [17067], [11717], [17815], [12527], [12424], [1150],
[10389], [2426], [734], [2224], [3502], [6253], [13555], [6673], [19303],
[2426], [4642], [2905], [14056]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">5? united
you're welcome![[6378], [3488], [16333]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">------------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">İt divides
the data to learning and validation parts<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">x_train=
x_values_array[:14000]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train=
y_values_array[:14000]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">x_val=
x_values_array[14000:]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_val=
y_values_array[14000:]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">---------------------------------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The last
program for learning is the transformer architecture as given in the Keras
reference above.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">But there is
still an enormous difficulty. The
x_train y_train data that you have prepared does not work with the given
architecture. A very important part of
creating an artificial neural network is to adjust the format of the input data
to the decided architecture. <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">First you
have to decide the max length of the text.
And then you have to pad your input texts according to this size. After some processing for flattening the
data, converting to numpy and than to tensors the network accepts the input.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">There is an
iterative performance improvement phase after the network begins to work and
produce some accuracy. Leraning rate
scheduling based on val_accuracy, layer normalization, droputs etc...<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The result for
learning is:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Model:
"model"<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">_________________________________________________________________<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> Layer (type) Output Shape Param # <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">=================================================================<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> input_1 (InputLayer) [(None, 100)] 0 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> token_and_position_embeddi (None, 100, 32) 643200 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> ng_8 (TokenAndPositionEmbe <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dding)
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> transformer_block_16 (Tran (None, 100, 32) 10656 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> sformerBlock)
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> transformer_block_17 (Tran (None, 100, 32) 10656 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> sformerBlock)
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> global_average_pooling1d ( (None, 32) 0 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> GlobalAveragePooling1D) <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> layer_normalization_36 (La (None, 32) 64 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> yerNormalization) <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dropout_36 (Dropout) (None, 32) 0 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dense_36 (Dense) (None, 20) 660 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> layer_normalization_37 (La (None, 20) 40 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> yerNormalization) <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dropout_37 (Dropout) (None, 20) 0 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> dense_37 (Dense) (None, 2) 42 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">=================================================================<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Total
params: 665318 (2.54 MB)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Trainable
params: 665318 (2.54 MB)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Non-trainable
params: 0 (0.00 Byte)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">_________________________________________________________________<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 1/2<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">110/110
[==============================] - ETA: 0s - loss: 0.5824 - accuracy:
0.6614 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Reduced
learning rate: 1.0000000474974512e-06<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">val_accuracy
= 0.8716470003128052<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">110/110
[==============================] - 53s 409ms/step - loss: 0.5824 - accuracy:
0.6614 - val_loss: 0.3216 - val_accuracy: 0.8716<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Epoch 2/2<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">110/110
[==============================] - ETA: 0s - loss: 0.2878 - accuracy: 0.8939 <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Reduced
learning rate: 9.999999974752428e-10<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">val_accuracy
= 0.8799197673797607<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">110/110
[==============================] - 45s 410ms/step - loss: 0.2878 - accuracy:
0.8939 - val_loss: 0.2996 - val_accuracy: 0.8799<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">new reviews:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> ["virginamerica it was amazing and
arrived an hour early you're too good to me", 'virginamerica your chat
support is not working on your site']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">************************************TESTTTTTTTTTTTT<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train------------->
tf.Tensor([1. 0. 1. 1. 1. 1. 0. 0. 0. 1.], shape=(10,), dtype=float32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_val------------->
tf.Tensor([1. 1. 0. 0. 0. 0. 0. 0. 0. 1.], shape=(10,), dtype=float32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 1s 863ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
0:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.1222235 0.8777765]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [1.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 42ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
1:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.12541966 0.8745803 ]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [1.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 111ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
2:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.80272907 0.19727091]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [0]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [0.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 40ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
3:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.95607054 0.04392945]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [0]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [0.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 41ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
4:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.9571833 0.04281674]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [0]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [0.]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">------------------------------------------------------------------------------------------------
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">The result
for prediction is:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">runfile('C:/Users/ars/ARStensorflow/sentimentAnalysis/saSTEP9/saPredictSingleTST.py',
wdir='C:/Users/ars/ARStensorflow/sentimentAnalysis/saSTEP9')<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">this<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[-0.5667038]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">is<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[0.43231726]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">my<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[0.78149366]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">book<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[0.48123372]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vectors=
[array([-0.5667038], dtype=float32), array([0.43231726], dtype=float32),
array([0.78149366], dtype=float32), array([0.48123372], dtype=float32)] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">discretized_sentence=
[[ 2986]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [ 9869]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [12275]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [10206]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Reloaded
modules: customSplitText, padSequences, flattenList2, saDiscretize<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">this<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[-0.5667038]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">is<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[0.43231726]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">my<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[0.78149366]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">book<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vector=
[0.48123372]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">word_vectors=
[array([-0.5667038], dtype=float32), array([0.43231726], dtype=float32),
array([0.78149366], dtype=float32), array([0.48123372], dtype=float32)] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">discretized_sentence=
[[ 2986]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [ 9869]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [12275]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [10206]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">line=
4901!positive& southwestair i continue to be amazed by the amazing customer
service thank you swa<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">result=
['4901', 'positive', ' southwestair i continue to be amazed by the amazing
customer service thank you swa']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i=0
sentence= southwestair i continue to be amazed by the amazing customer service
thank you swa w2v=[[8442], [466], [12816], [9340], [4598], [4829], [737],
[793], [6358], [3151], [12167], [11772], [9432], [1910]] sentiment=1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">line=
14471!negative& americanair golfwithwoody don't buy it woody they're making
it much worse with understaffing rudeness and prerookie mistakes<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">result=
['14471', 'negative', " americanair golfwithwoody don't buy it woody
they're making it much worse with understaffing rudeness and prerookie
mistakes"]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i=1
sentence= americanair golfwithwoody don't buy it woody they're making it much
worse with understaffing rudeness and prerookie mistakes w2v=[[9886], [2127],
[7499], [135], [9532], [11515], [3271], [4734], [9532], [12749], [12123],
[8706], [5099], [11521], [2413], [6925], [9551]] sentiment=0<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">line=
11384!positive& usairways thanks to betty working gate at ilm and lovely
gate agents here in clt helping me get home 2 phx tonight instead of tomorrow<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">result=
['11384', 'positive', ' usairways thanks to betty working gate at ilm and
lovely gate agents here in clt helping me get home 2 phx tonight instead of
tomorrow']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i=2
sentence= usairways thanks to betty working gate at ilm and lovely gate agents
here in clt helping me get home 2 phx tonight instead of tomorrow w2v=[[6451],
[11881], [9340], [2553], [11385], [5975], [12647], [11985], [2413], [8438],
[5975], [10011], [5168], [12028], [11130], [4376], [10337], [11710], [9390],
[4244], [1618], [1996], [13019], [4799]] sentiment=1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">line=
4668!positive& southwestair i'll stick with flying for free any where that
southwest goes my son works for this wonderful company and moms fly free<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">result=
['4668', 'positive', " southwestair i'll stick with flying for free any
where that southwest goes my son works for this wonderful company and moms fly
free"]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i=3
sentence= southwestair i'll stick with flying for free any where that southwest
goes my son works for this wonderful company and moms fly free w2v=[[8442],
[7274], [2025], [8706], [4803], [2867], [4455], [2257], [7714], [11791],
[5805], [4932], [12275], [3245], [2515], [2867], [2986], [3296], [10500],
[2413], [11024], [8239], [4455]] sentiment=1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">line=
6172!positive& southwestair is there a way to know who checked my bag on
the curb she was awesome and want to be sure she gets a high five<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">result=
['6172', 'positive', ' southwestair is there a way to know who checked my bag
on the curb she was awesome and want to be sure she gets a high five']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i=4
sentence= southwestair is there a way to know who checked my bag on the curb
she was awesome and want to be sure she gets a high five w2v=[[8442], [9869],
[1617], [2539], [9340], [8282], [11759], [8073], [12275], [8631], [8560],
[793], [7158], [1672], [506], [1532], [2413], [4309], [9340], [4598], [13300],
[1672], [3199], [2002], [9685]] sentiment=1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">line=
3402!positive& united you're welcome<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">result=
['3402', 'positive', " united you're welcome"]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">i=5
sentence= united you're welcome w2v=[[4394], [2404], [11254]] sentiment=1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">0?
southwestair i continue to be amazed by the amazing customer service thank you
swa![[8442], [466], [12816], [9340], [4598], [4829], [737], [793], [6358],
[3151], [12167], [11772], [9432], [1910]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1?
americanair golfwithwoody don't buy it woody they're making it much worse with
understaffing rudeness and prerookie mistakes![[9886], [2127], [7499], [135],
[9532], [11515], [3271], [4734], [9532], [12749], [12123], [8706], [5099],
[11521], [2413], [6925], [9551]]&0<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">2? usairways
thanks to betty working gate at ilm and lovely gate agents here in clt helping
me get home 2 phx tonight instead of tomorrow![[6451], [11881], [9340], [2553],
[11385], [5975], [12647], [11985], [2413], [8438], [5975], [10011], [5168],
[12028], [11130], [4376], [10337], [11710], [9390], [4244], [1618], [1996],
[13019], [4799]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">3?
southwestair i'll stick with flying for free any where that southwest goes my
son works for this wonderful company and moms fly free![[8442], [7274], [2025],
[8706], [4803], [2867], [4455], [2257], [7714], [11791], [5805], [4932],
[12275], [3245], [2515], [2867], [2986], [3296], [10500], [2413], [11024],
[8239], [4455]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">4?
southwestair is there a way to know who checked my bag on the curb she was
awesome and want to be sure she gets a high five![[8442], [9869], [1617],
[2539], [9340], [8282], [11759], [8073], [12275], [8631], [8560], [793],
[7158], [1672], [506], [1532], [2413], [4309], [9340], [4598], [13300], [1672],
[3199], [2002], [9685]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">5? united
you're welcome![[4394], [2404], [11254]]&1<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">x_values------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">['[[8442],
[466], [12816], [9340], [4598], [4829], [737], [793], [6358], [3151], [12167],
[11772], [9432], [1910]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[9886], [2127], [7499], [135], [9532],
[11515], [3271], [4734], [9532], [12749], [12123], [8706], [5099], [11521], [2413],
[6925], [9551]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[6451], [11881], [9340], [2553], [11385],
[5975], [12647], [11985], [2413], [8438], [5975], [10011], [5168], [12028],
[11130], [4376], [10337], [11710], [9390], [4244], [1618], [1996], [13019],
[4799]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[8442], [7274], [2025], [8706], [4803],
[2867], [4455], [2257], [7714], [11791], [5805], [4932], [12275], [3245],
[2515], [2867], [2986], [3296], [10500], [2413], [11024], [8239], [4455]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[8442], [9869], [1617], [2539], [9340],
[8282], [11759], [8073], [12275], [8631], [8560], [793], [7158], [1672], [506],
[1532], [2413], [4309], [9340], [4598], [13300], [1672], [3199], [2002],
[9685]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[4394], [2404], [11254]]']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_values*********<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">['1' '0' '1'
'1' '1' '1']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">------------<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">?????????????????????????????x_train<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">['[[8442],
[466], [12816], [9340], [4598], [4829], [737], [793], [6358], [3151], [12167],
[11772], [9432], [1910]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[9886], [2127], [7499], [135], [9532],
[11515], [3271], [4734], [9532], [12749], [12123], [8706], [5099], [11521],
[2413], [6925], [9551]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[6451], [11881], [9340], [2553], [11385],
[5975], [12647], [11985], [2413], [8438], [5975], [10011], [5168], [12028],
[11130], [4376], [10337], [11710], [9390], [4244], [1618], [1996], [13019],
[4799]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[8442], [7274], [2025], [8706], [4803], [2867],
[4455], [2257], [7714], [11791], [5805], [4932], [12275], [3245], [2515],
[2867], [2986], [3296], [10500], [2413], [11024], [8239], [4455]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[8442], [9869], [1617], [2539], [9340],
[8282], [11759], [8073], [12275], [8631], [8560], [793], [7158], [1672], [506],
[1532], [2413], [4309], [9340], [4598], [13300], [1672], [3199], [2002],
[9685]]'<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> '[[4394], [2404], [11254]]']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">['1' '0' '1'
'1' '1' '1']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Shape of
x_train: (6,)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Shape of
y_train: (6,)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">:::::::::::::::::::::::::::::::::<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">x_train_loaded===============
[[[8442], [466], [12816], [9340], [4598], [4829], [737], [793], [6358], [3151],
[12167], [11772], [9432], [1910]], [[9886], [2127], [7499], [135], [9532],
[11515], [3271], [4734], [9532], [12749], [12123], [8706], [5099], [11521],
[2413], [6925], [9551]], [[6451], [11881], [9340], [2553], [11385], [5975],
[12647], [11985], [2413], [8438], [5975], [10011], [5168], [12028], [11130],
[4376], [10337], [11710], [9390], [4244], [1618], [1996], [13019], [4799]],
[[8442], [7274], [2025], [8706], [4803], [2867], [4455], [2257], [7714],
[11791], [5805], [4932], [12275], [3245], [2515], [2867], [2986], [3296],
[10500], [2413], [11024], [8239], [4455]], [[8442], [9869], [1617], [2539],
[9340], [8282], [11759], [8073], [12275], [8631], [8560], [793], [7158],
[1672], [506], [1532], [2413], [4309], [9340], [4598], [13300], [1672], [3199],
[2002], [9685]], [[4394], [2404], [11254]]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 1
length: 14<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 2
length: 17<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 3
length: 24<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 4
length: 23<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 5
length: 25<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 6
length: 3<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">x_train
padded=============== [[[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [8442], [466], [12816], [9340], [4598], [4829], [737], [793], [6358],
[3151], [12167], [11772], [9432], [1910]], [[0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [9886], [2127], [7499], [135], [9532], [11515], [3271], [4734], [9532],
[12749], [12123], [8706], [5099], [11521], [2413], [6925], [9551]], [[0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [6451], [11881],
[9340], [2553], [11385], [5975], [12647], [11985], [2413], [8438], [5975],
[10011], [5168], [12028], [11130], [4376], [10337], [11710], [9390], [4244],
[1618], [1996], [13019], [4799]], [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [8442], [7274], [2025], [8706], [4803], [2867],
[4455], [2257], [7714], [11791], [5805], [4932], [12275], [3245], [2515],
[2867], [2986], [3296], [10500], [2413], [11024], [8239], [4455]], [[0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [8442], [9869], [1617],
[2539], [9340], [8282], [11759], [8073], [12275], [8631], [8560], [793],
[7158], [1672], [506], [1532], [2413], [4309], [9340], [4598], [13300], [1672],
[3199], [2002], [9685]], [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0],
[0.0], [0.0], [4394], [2404], [11254]]] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> x_train padded length= 6<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 1
length: 100<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 2
length: 100<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 3
length: 100<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 4
length: 100<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 5
length: 100<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Sublist 6
length: 100<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">x_train
flatened=============== [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 8442, 466, 12816,
9340, 4598, 4829, 737, 793, 6358, 3151, 12167, 11772, 9432, 1910], [0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 9886, 2127, 7499, 135, 9532, 11515, 3271, 4734, 9532, 12749, 12123, 8706,
5099, 11521, 2413, 6925, 9551], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 6451, 11881, 9340, 2553, 11385, 5975, 12647, 11985, 2413, 8438,
5975, 10011, 5168, 12028, 11130, 4376, 10337, 11710, 9390, 4244, 1618, 1996,
13019, 4799], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
8442, 7274, 2025, 8706, 4803, 2867, 4455, 2257, 7714, 11791, 5805, 4932, 12275,
3245, 2515, 2867, 2986, 3296, 10500, 2413, 11024, 8239, 4455], [0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 8442, 9869, 1617, 2539, 9340, 8282,
11759, 8073, 12275, 8631, 8560, 793, 7158, 1672, 506, 1532, 2413, 4309, 9340,
4598, 13300, 1672, 3199, 2002, 9685], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4394, 2404, 11254]] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> x_train length= 6<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------->>>>>>>>>>>>>
tf.Tensor(<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">[[ 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 8442.
466. 12816. 9340.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 4598.
4829. 737. 793.
6358. 3151. 12167. 11772. 9432.
1910.]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [
0. 0. 0.
0. 0. 0.
0. 0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0.
0. 0. 0.
0. 0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 9886.
2127. 7499. 135.
9532. 11515. 3271.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 4734.
9532. 12749. 12123. 8706. 5099. 11521.
2413. 6925. 9551.]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [
0. 0. 0.
0. 0. 0.
0. 0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 6451. 11881.
9340. 2553.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 11385.
5975. 12647. 11985. 2413. 8438.
5975. 10011. 5168. 12028.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 11130.
4376. 10337. 11710. 9390. 4244.
1618. 1996. 13019. 4799.]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [
0. 0. 0.
0. 0. 0.
0. 0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
8442. 7274. 2025.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 8706.
4803. 2867. 4455.
2257. 7714. 11791. 5805.
4932. 12275.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 3245.
2515. 2867. 2986.
3296. 10500. 2413. 11024. 8239.
4455.]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [
0. 0. 0.
0. 0. 0.
0. 0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 8442. 9869.
1617. 2539. 9340.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 8282. 11759.
8073. 12275. 8631. 8560.
793. 7158. 1672.
506.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 1532.
2413. 4309. 9340.
4598. 13300. 1672. 3199.
2002. 9685.]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> [
0. 0. 0.
0. 0. 0.
0. 0. 0.
0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"> 0.
0. 0. 0.
0. 0. 0.
4394. 2404. 11254.]], shape=(6,
100), dtype=float32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">----------x_train_tensor---->>>>---->>>>>
tf.Tensor(2, shape=(), dtype=int32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">----------x_train---->>>>---->>>>>
tf.Tensor(2, shape=(), dtype=int32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train=['1'
'0' '1' '1' '1' '1']<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train=[1,
0, 1, 1, 1, 1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">-------------->>>>>>>>>>>>>
tf.Tensor([1. 0. 1. 1. 1. 1.], shape=(6,), dtype=float32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train=<tf.Variable
'Variable:0' shape=(6,) dtype=float32, numpy=array([1., 0., 1., 1., 1., 1.],
dtype=float32)><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">:::::::::::::::::::::::::::::::::<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">y_train------------->
tf.Tensor([1. 0. 1. 1. 1. 1.], shape=(6,), dtype=float32)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 1s 954ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
0:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.49673203 0.50326794]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [1.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 33ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
1:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.49673203 0.50326794]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [0.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 32ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
2:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.49673203 0.50326794]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [1.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 31ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
3:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.49673203 0.50326794]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [1.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">1/1
[==============================] - 0s 30ms/step<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">&&&&&&&&&&&&&&&&Input
4:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
probabilities: [[0.49673203 0.50326794]]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Predicted
class: [1]<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">Actual
class: [1.] <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><o:p> </o:p></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-8587170692700814172023-08-13T00:07:00.013-07:002023-08-13T00:59:47.409-07:00How to Prepare Data for a Neural Network: A Step-by-Step Guide<p style="text-align: center;"> <b style="text-align: center;"><span style="color: red; font-size: 12pt; line-height: 115%;">How to Prepare Data for a Neural Network: A Step-by-Step Guide</span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; mso-themecolor: text2; mso-themetint: 153;"> </span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; mso-themecolor: text2; mso-themetint: 153;">Introduction<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">In this
guide, I'll walk you through the steps I took to prepare airline sentiment data
for a neural network. The aim is to create a model that predicts whether new
comments are positive or negative using word embeddings and a transformer
neural network architecture.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; font-size: 12pt; line-height: 115%; mso-themecolor: text2; mso-themetint: 153;">Step 0: Data Collection<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">I began by
obtaining the 'airline twitter sentiment' data from Data World
(https://data.world/datasets/sentiment). This dataset includes customer
comments and their associated sentiments.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitHK_Zmy45ybkZeRNFAOlEDyM5NfU9v1MCXxlFGaAcgKdByXA9AEYNr8vkttviZkCjjLV8ejimWyhfmEdQIFOclE_6rP7ZAJ-r2BAaQl29ZAF3DztRGph1XCjP6S5Kn436mVtOLwggCvqqsMqgkMnow-r9GOJ1tbg1NuLkifWBFTtZhmQLIMDh7AY6L6bh/s1024/Airline-SentimentARS1xslxSCREEN.jpg" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="556" data-original-width="1024" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitHK_Zmy45ybkZeRNFAOlEDyM5NfU9v1MCXxlFGaAcgKdByXA9AEYNr8vkttviZkCjjLV8ejimWyhfmEdQIFOclE_6rP7ZAJ-r2BAaQl29ZAF3DztRGph1XCjP6S5Kn436mVtOLwggCvqqsMqgkMnow-r9GOJ1tbg1NuLkifWBFTtZhmQLIMDh7AY6L6bh/w400-h217/Airline-SentimentARS1xslxSCREEN.jpg" width="400" /></a> </p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; font-size: 12pt; line-height: 115%; mso-themecolor: text2; mso-themetint: 153;">Step 1: Data Cleaning and Text Extraction<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">First, I
extracted customer comments from the 'text' field of the dataset and cleaned
them by removing punctuation, numbers, and other irrelevant elements. The
cleaned comments were then written to a text file called
"saPreprocessSentences.txt." This process was implemented using the
following Python code:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># saPreprocessClean.py<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">from saPreprocessClean import clean_string<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Load the dataset<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">df = pd.read_excel('/Users/ARS/ARStensorflow/Airline-SentimentARS1.xlsx')<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Clean and preprocess the comments<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">cleaned_comments = ""<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">for value in df['text']:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> if
isinstance(value, str):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> clean_string =
clean_string(value)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
cleaned_comments += ' ' + clean_string<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Write cleaned comments to file<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">with open("saPreprocessSentences.txt",
"w") as file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><span style="font-size: 9pt; line-height: 115%;">
file.write(cleaned_comments)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; font-size: 12pt; line-height: 115%; mso-themecolor: text2; mso-themetint: 153;">Step 2: Word Extraction and Cleaning<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Next, I
extracted individual words from the cleaned comments, further cleaned them, and
saved them to a file called "saPreprocessWords.txt." The code to
achieve this is as follows:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># saPreprocessWords.py<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">from saPreprocessClean import clean_string<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Load the dataset<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">df =
pd.read_excel('/Users/ARS/ARStensorflow/sentimentAnalysis/Airline-SentimentARS1.xlsx')<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Extract and preprocess words from comments<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">with open("saPreprocessWords.txt", "w")
as file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> for value in
df['text']:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> if
isinstance(value, str):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> words =
value.split()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> for word in
words:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
clean_word = clean_string(word)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
file.write(f"word={word} cleaned={clean_word}\n")<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; font-size: 12pt; line-height: 115%; mso-themecolor: text2; mso-themetint: 153;">Step 3: Removing Duplicate Entries<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">To ensure
data integrity, I created a batch program called "removeDUP" to
remove any duplicate entries from the "saPreprocessWords.txt" file.
The cleaned output was saved to "saRemoveDUPOutput.txt."<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; font-size: 12pt; line-height: 115%; mso-themecolor: text2; mso-themetint: 153;">Step 4: Creating Word Embeddings<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">I converted
each unique word into a float value using word2vec embeddings and built a
dictionary model to map words to their corresponding vectors. This model was
saved as "word2vec_dict_model.model," and the vectors were stored in
"saW2Vdict_vectors.txt."<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in; text-indent: 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">#
saCreateW2VDictModel.py<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">from gensim.models import Word2Vec<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Load the cleaned word list<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">with open("saRemoveDUPOutput2.txt", "r",
encoding="utf-16-le") as file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> words =
[line.strip().split()[1] for line in file]<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Build and train the word2vec model<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">model = Word2Vec.load("word2vec_dict_model.model")<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">for new_word in words:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> if
any(char.isdigit() for char in new_word):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
print(f"includes number --> {new_word}")<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> else:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
model.build_vocab([new_word], update=True)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
model.train([new_word], total_examples=1, epochs=1)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">model.save("word2vec_dict_model.model")<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">model.wv.save_word2vec_format("saW2Vdict_vectors.txt",
binary=False)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; font-size: 12pt; line-height: 115%; mso-themecolor: text2; mso-themetint: 153;">Step 5: Data Transformation and Labeling<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">I
transformed the sentences in "saPreprocessSentences.txt" into
word2vec vectors using the dictionary model. I also labeled each sentence based
on its sentiment, appending it to the "saW2VXtrainYtrainData.txt"
file.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Transform sentences to word2vec vectors and label<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">def get_w2v_sentence(sentence):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> word_vectors =
[model.wv[word] for word in sentence.split() if word in model.wv]<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> return word_vectors<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Load the word2vec model<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">model = Word2Vec.load("word2vec_model_updated.model")<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Load sentiment data<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">df =
pd.read_excel('/Users/ARS/ARStensorflow/Airline-SentimentARS1.xlsx')<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">sentiments = []<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">for sentiment_value in df['airline_sentiment']:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> if sentiment_value
== "positive":<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> sentiments.append(1)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">with open("saPreprocessSentences.txt",
"r") as file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> with
open("saW2VXtrainYtrainData.txt", "w") as file2:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> i = 0<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> for line in
file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> sentence =
line.strip()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
w2v_sentence_vectors = get_w2v_sentence(sentence)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
w2v_sentence_lists = [vector.tolist() for vector in
w2v_sentence_vectors]<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
print(f"i={i} w2v={w2v_sentence_lists}
sentiment={sentiments[i]}", file=file2)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> i += 1<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Reading and formatting the data<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">x_values = []<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">y_values = []<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">with open("saW2VXtrainYtrainData.txt",
"r") as file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> for line in file:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> parts =
line.strip().split()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> x_value =
[float(x) for x in parts[1].split(',')]<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> y_value =
int(parts[2])<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
x_values.append(x_value)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">
y_values.append(y_value)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">x_values_array = np.array(x_values)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">y_values_array = np.array(y_values)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">Step 6: Splitting Data for Training and Validation<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">I split the data into training and validation sets using a
train-validation ratio of 80-20. The resulting arrays were saved as
"saXtrainYtrainData.npz."<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">python<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">Copy code<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">from sklearn.model_selection import train_test_split<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Split data into training and validation sets<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">x_train, x_val, y_train, y_val = train_test_split(<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> x_values_array,
y_values_array, test_size=val_ratio, random_state=42<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;"># Save the arrays to a file<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in; margin-left: 35.4pt; margin-right: 0in; margin-top: 0in; margin: 0in 0in 0in 35.4pt;"><span style="font-size: 9pt; line-height: 115%;">np.savez("saXtrainYtrainData.npz", x_train=x_train,
x_val=x_val, y_train=y_train, y_val=y_val)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><b><span style="color: #548dd4; mso-themecolor: text2; mso-themetint: 153;">Conclusion<o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">By following
these steps, I successfully prepared the airline sentiment data for training a
transformer neural network. The data, which includes word2vec-transformed
sentences and corresponding sentiment labels, is ready to be used for building
and training the neural network model. This process showcases the power of chatGPT
in aiding and accelerating the programming process.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">#neuralNetworks #dataPrepare </p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;">runfile('C:/Users/ars/ARStensorflow/sentimentAnalysis/saSTEP7/saProduceXtrainYtrainDataNEW.py', wdir='C:/Users/ars/ARStensorflow/sentimentAnalysis/saSTEP7')</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = neutral -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = positive -->1</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = neutral -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = negative -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = negative -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = negative -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = positive -->1</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = neutral -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = positive -->1</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = positive -->1</p><p class="MsoNormal" style="margin-bottom: 0in;">sentiment = neutral -->0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=0 = </p><p class="MsoNormal" style="margin-bottom: 0in;">i=0 w2v=[] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=1 = virginamerica plus you've added commercials to the experience tacky</p><p class="MsoNormal" style="margin-bottom: 0in;">i=1 w2v=[[0.0012580156326293945], [-0.6498260498046875], [-0.5153262615203857], [-0.020553112030029297], [-0.6892403364181519], [0.3554692268371582], [-0.8850120306015015], [-0.2642437219619751], [0.10036587715148926]] sentiment=1</p><p class="MsoNormal" style="margin-bottom: 0in;">i=2 = virginamerica i didn't today must mean i need to take another trip</p><p class="MsoNormal" style="margin-bottom: 0in;">i=2 w2v=[[0.0012580156326293945], [-0.932395339012146], [0.2726396322250366], [-0.6015644073486328], [-0.01267862319946289], [-0.4461408853530884], [-0.932395339012146], [-0.946296215057373], [0.3554692268371582], [0.02413642406463623], [0.9904971122741699], [0.6381527185440063]] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=3 = virginamerica it's really aggressive to blast obnoxious entertainment in your guests' faces amp they have little recourse</p><p class="MsoNormal" style="margin-bottom: 0in;">i=3 w2v=[[0.0012580156326293945], [-0.7756330966949463], [-0.5128778219223022], [-0.5935169458389282], [0.3554692268371582], [-0.942463755607605], [0.03211188316345215], [-0.1338428258895874], [0.7456883192062378], [0.9946664571762085], [-0.31516337394714355], [-0.22687816619873047], [0.2923257350921631], [0.6583085060119629], [0.6221826076507568], [-0.5303181409835815], [0.7077651023864746]] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=4 = virginamerica and it's a really big bad thing about it</p><p class="MsoNormal" style="margin-bottom: 0in;">i=4 w2v=[[0.0012580156326293945], [-0.6498693227767944], [-0.7756330966949463], [-0.5128778219223022], [0.98853600025177], [0.7764592170715332], [0.9213329553604126], [0.9233143329620361], [0.3834136724472046]] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=5 = virginamerica seriously would pay 30 a flight for seats that didn't have this playing it's really the only bad thing about flying va</p><p class="MsoNormal" style="margin-bottom: 0in;">i=5 w2v=[[0.0012580156326293945], [0.48972034454345703], [0.81987464427948], [-0.03148186206817627], [-0.7918610572814941], [-0.5839154720306396], [-0.767822265625], [0.7113058567047119], [0.2726396322250366], [0.6221826076507568], [-0.5667037963867188], [0.7418577671051025], [-0.7756330966949463], [-0.5128778219223022], [-0.8850120306015015], [0.8083392381668091], [0.7764592170715332], [0.9213329553604126], [0.9233143329620361], [-0.3030076026916504], [-0.29737353324890137]] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=6 = virginamerica really missed a prime opportunity for men without hats parody there</p><p class="MsoNormal" style="margin-bottom: 0in;">i=6 w2v=[[0.0012580156326293945], [-0.5128778219223022], [-0.9224623441696167], [-0.2657853364944458], [-0.10833430290222168], [-0.5839154720306396], [0.42132532596588135], [0.7914493083953857], [0.4627121686935425], [-0.3580136299133301], [-0.7653474807739258]] sentiment=1</p><p class="MsoNormal" style="margin-bottom: 0in;">i=7 = virginamerica well i didn'tûbut now i do d</p><p class="MsoNormal" style="margin-bottom: 0in;">i=7 w2v=[[0.0012580156326293945], [0.28537607192993164], [-0.932395339012146], [-0.4359729290008545], [0.019797325134277344], [-0.932395339012146], [-0.1655644178390503], [0.6342606544494629]] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;">i=8 = virginamerica it was amazing and arrived an hour early you're too good to me</p><p class="MsoNormal" style="margin-bottom: 0in;">i=8 w2v=[[0.0012580156326293945], [0.3834136724472046], [-0.9266262054443359], [-0.0772627592086792], [-0.6498693227767944], [0.427449107170105], [0.07871925830841064], [0.5342621803283691], [-0.6033754348754883], [-0.6512038707733154], [-0.5308046340942383], [-0.4651916027069092], [0.3554692268371582], [0.500235915184021]] sentiment=1</p><p class="MsoNormal" style="margin-bottom: 0in;">i=9 = virginamerica did you know that suicide is the second leading cause of death among teens 1024</p><p class="MsoNormal" style="margin-bottom: 0in;">i=9 w2v=[[0.0012580156326293945], [-0.12914776802062988], [0.36882483959198], [0.20193088054656982], [0.7113058567047119], [-0.4647252559661865], [0.43231725692749023], [-0.8850120306015015], [0.8175731897354126], [0.1814650297164917], [0.9735549688339233], [0.8894059658050537], [-0.048635125160217285], [0.7589428424835205], [-0.8305487632751465]] sentiment=1</p><p class="MsoNormal" style="margin-bottom: 0in;">i=10 = virginamerica i lt3 pretty graphics so much better than minimal iconography d</p><p class="MsoNormal" style="margin-bottom: 0in;">i=10 w2v=[[0.0012580156326293945], [-0.932395339012146], [-0.6855369806289673], [0.13977575302124023], [-0.11634397506713867], [0.8503241539001465], [0.973355770111084], [-0.6604783535003662], [-0.5532848834991455], [0.3296027183532715], [0.6342606544494629]] sentiment=0</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;">['[]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.6498260498046875], [-0.5153262615203857], [-0.020553112030029297], [-0.6892403364181519], [0.3554692268371582], [-0.8850120306015015], [-0.2642437219619751], [0.10036587715148926]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.932395339012146], [0.2726396322250366], [-0.6015644073486328], [-0.01267862319946289], [-0.4461408853530884], [-0.932395339012146], [-0.946296215057373], [0.3554692268371582], [0.02413642406463623], [0.9904971122741699], [0.6381527185440063]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.7756330966949463], [-0.5128778219223022], [-0.5935169458389282], [0.3554692268371582], [-0.942463755607605], [0.03211188316345215], [-0.1338428258895874], [0.7456883192062378], [0.9946664571762085], [-0.31516337394714355], [-0.22687816619873047], [0.2923257350921631], [0.6583085060119629], [0.6221826076507568], [-0.5303181409835815], [0.7077651023864746]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.6498693227767944], [-0.7756330966949463], [-0.5128778219223022], [0.98853600025177], [0.7764592170715332], [0.9213329553604126], [0.9233143329620361], [0.3834136724472046]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [0.48972034454345703], [0.81987464427948], [-0.03148186206817627], [-0.7918610572814941], [-0.5839154720306396], [-0.767822265625], [0.7113058567047119], [0.2726396322250366], [0.6221826076507568], [-0.5667037963867188], [0.7418577671051025], [-0.7756330966949463], [-0.5128778219223022], [-0.8850120306015015], [0.8083392381668091], [0.7764592170715332], [0.9213329553604126], [0.9233143329620361], [-0.3030076026916504], [-0.29737353324890137]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.5128778219223022], [-0.9224623441696167], [-0.2657853364944458], [-0.10833430290222168], [-0.5839154720306396], [0.42132532596588135], [0.7914493083953857], [0.4627121686935425], [-0.3580136299133301], [-0.7653474807739258]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [0.28537607192993164], [-0.932395339012146], [-0.4359729290008545], [0.019797325134277344], [-0.932395339012146], [-0.1655644178390503], [0.6342606544494629]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [0.3834136724472046], [-0.9266262054443359], [-0.0772627592086792], [-0.6498693227767944], [0.427449107170105], [0.07871925830841064], [0.5342621803283691], [-0.6033754348754883], [-0.6512038707733154], [-0.5308046340942383], [-0.4651916027069092], [0.3554692268371582], [0.500235915184021]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.12914776802062988], [0.36882483959198], [0.20193088054656982], [0.7113058567047119], [-0.4647252559661865], [0.43231725692749023], [-0.8850120306015015], [0.8175731897354126], [0.1814650297164917], [0.9735549688339233], [0.8894059658050537], [-0.048635125160217285], [0.7589428424835205], [-0.8305487632751465]]'</p><p class="MsoNormal" style="margin-bottom: 0in;"> '[[0.0012580156326293945], [-0.932395339012146], [-0.6855369806289673], [0.13977575302124023], [-0.11634397506713867], [0.8503241539001465], [0.973355770111084], [-0.6604783535003662], [-0.5532848834991455], [0.3296027183532715], [0.6342606544494629]]']</p><p class="MsoNormal" style="margin-bottom: 0in;">['0' '1' '0' '0' '0' '0' '1' '0' '1' '1' '0']</p><p class="MsoNormal" style="margin-bottom: 0in;">------------</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of x_train: (8,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of y_train: (8,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of x_val: (3,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of y_val: (3,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of x_train_loaded: (8,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of x_val_loaded: (3,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of y_train_loaded: (8,)</p><p class="MsoNormal" style="margin-bottom: 0in;">Shape of y_val_loaded: (3,)</p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-31087380369885462402022-08-21T01:54:00.021-07:002022-08-21T01:57:43.455-07:00The Skills of Encouragement<p> </p><p class="MsoListParagraphCxSpMiddle">The Skills of Encouragement<o:p></o:p></p><p class="MsoListParagraphCxSpMiddle">Bringing out the Best in Yourself and Others<o:p></o:p></p><p class="MsoListParagraphCxSpMiddle">Dr. Don DINKMAYER<o:p></o:p></p><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;">Dr. Lewis LOSONCY</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjATb4-pXrtqBggEIm-682Bg-FTGmgVwJEQ_G5ZixVhI9nXaSXlSqeq3P3tjNmI5F5CbVjc5vKaKv2tdTJvE9KLyLBn49mTqJLwyAEqlpVLzXRPcZSlRWmkUGWEEM_hlDALUiUfEkErUIAuns6zhQ_kLh9ouKzcTbud5x0gyMxiMx4ax9l1kcH2bgFiEQ/s603/ist3.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="603" data-original-width="407" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjATb4-pXrtqBggEIm-682Bg-FTGmgVwJEQ_G5ZixVhI9nXaSXlSqeq3P3tjNmI5F5CbVjc5vKaKv2tdTJvE9KLyLBn49mTqJLwyAEqlpVLzXRPcZSlRWmkUGWEEM_hlDALUiUfEkErUIAuns6zhQ_kLh9ouKzcTbud5x0gyMxiMx4ax9l1kcH2bgFiEQ/s320/ist3.jpg" width="216" /></a></div><br /><p></p><p class="MsoNormal">The Skill and Process of Getting High on Yourself</p><p class="MsoNormal"><o:p></o:p></p>
<p class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">1.<span style="font-size: xx-small;"> </span></span>1- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Listen and attend to
others.</span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">When you are in contact with
them, stop your preoccupation with what you are doing.</span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">Listen and be in a position to hear the whole
message.</span></p><p class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">2.<span style="font: 7pt "Times New Roman";"> </span></span></span>2- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Before you talk with
others, clarify the message they have sent to you. “I hear what you are saying,
feeling, etc.”</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">3.<span style="font: 7pt "Times New Roman";"> </span></span></span>3- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Use put-ups instead of
put-downs.</span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">What are somethings </span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">you could do to help build the other person’s
self-esteem.</span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">What could you say that is
positive?</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">4.<span style="font: 7pt "Times New Roman";"> </span><span style="font-family: "Times New Roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> 4</span></span></span>- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Respond reflectively, while
continuing to stay with the other person’s feelings.</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">5.<span style="font: 7pt "Times New Roman";"> </span><span style="font-family: "Times New Roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">5-</span></span></span> <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Look for similarities.</span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">What do the two of you have in common?</span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">Where are some places you can universalize?</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">6.<span style="font: 7pt "Times New Roman";"> </span><span style="font-family: "Times New Roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> 6</span></span></span>- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Give them feedback on how
they are coming across to you.</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">7.<span style="font: 7pt "Times New Roman";"> </span><span style="font-family: "Times New Roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;">7</span></span></span>- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Encourage them for their strengths
and not their perfections.</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">8.<span style="font: 7pt "Times New Roman";"> </span><span style="font-family: "Times New Roman"; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> 8</span></span></span>- <span style="text-indent: -0.25in;"><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><span dir="LTR" style="text-indent: -0.25in;"></span><span style="text-indent: -0.25in;">Help them to see perceptual
alternatives or more positive, effective ways they can look at the world(page
31).</span></p><p class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle"><o:p> </o:p></p>
<p class="MsoListParagraphCxSpMiddle"><o:p> </o:p>Listening involves giving your full
attention to the person you are with. It
involves not only the content but the feelings, beliefs, and attitudes. The skilled listener then moves to
communicating the beliefs, feelings, and attitudes that he or she is
hearing. Through the simple process of
listening, being heard, and processing feedback, the other pserson starts to
feel encouraged and valued (page 36).</p><p class="MsoListParagraphCxSpMiddle"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle"><o:p> </o:p></p>
<p class="MsoListParagraphCxSpMiddle"><br /></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-18036599900790427262022-06-08T08:17:00.001-07:002022-06-08T08:17:23.691-07:00 LanganaT ne yapabilir, ne yapmalı?<p> LanganaT ne yapabilir, ne yapmalı?</p><div dir="ltr"><div><div><br /></div><div>1-Bir referans dosya ya da kitabı önceden batch olarak PARSE eder.</div><div>Özne ve nesneleri belirler.</div><div>2- Gelecek soruyu online olarak alır ve PARSE eder.</div><div>Özne ve nesneleri ayırır, soruyu belirler.</div><div>3- Soruya göre, örneğin bisikleti ilk kim yaptı? sorusuna göre,</div><div>arama metnini lokalize eder.</div><div>4- Odaklandığı metinler içinde bisiklet ve buldu kelimelerini</div><div>arar, o cümlenin öznesini bulur. </div><div>5- Bulduğu özneyi özel isimler listesinde kontrol eder.</div><div>6- Özneyi, soru cümlesinde 'kim' kelimesi yerine yerleştirir</div><div>ya da yeni bir cümle yapar ve soruyu cevaplar.</div><div><br /></div><div>Bu mantık herhangi bir uzmanlık alanında çok kalın kitaplardan</div><div>bilgi çıkartmak için kullanılabilir.</div><div><br /></div><div>Örneğin (İzmir Ege Tıp fakültesi hastahanesi başhekimi Adil ESEN (AFL78)</div><div>üroloji için hazırladıkları bir kitap metnini göndermişti bana.</div><div>Bu metnin işlenmesi Tıp deyimleri sözlüğünü gerektirir. Fakat</div><div>LanganaT PARSER'ı otomatik tarama ve bilgi bulma amacıyla kullanılabilir.)</div><div>Aynı mantık, İngilizce bir PARSER olmak şartı ile Uçak Bakım</div><div>sürecinde bakım süresini kısaltmak için kullanılabilir ve ekonomik</div><div>olarak çok yüksek artı değer getirir. (Yaptığım İngilizce tercüme</div><div>motorunda çok gelişmiş olmasa da bir İngilizce PARSER var).</div><div><br /></div><div>Anlamak bilmekten daha geniş ve derin bir kavram.</div><div>Bisikleti kim icad etti? sorusu Bisikleti ilk kim yaptı?</div><div>Bisikleti kim buldu? Bu üç soru da doğru ve aynı cevaplanmalı.</div><div><br /></div><div>Bu bir eş anlamlar sözlüğü, deyimler sözlüğü ve nihayet bir</div><div>thesaurus ve semantik sözlük gerektirir. Çok sınırlı bir deyimler sözlüğü</div><div>kullanıyor LanganaT. Sözlüklerin hazırlanması ise güçlü tarayıcı ve</div><div>bulucu programlar gerektiriyor.</div><div><br /></div><div>Bu programların geliştirilmesi için ise Türkçe CORPUS oluşturmak gerekiyor.</div><div>Corpusların seçilecek konuya hatta üsluba (gazete makalesi, bilimsel makale) </div><div>göre de seçilmesi gerekiyor. Elimde 1 milyon kelimelik sınırlı bir edebi </div><div>Corpus var. Bunun içinde bile dilin eskiliğine ve yazarlara göre farklılıklar var.</div><div> </div><div>AMAÇ: Büyük verilerin içerdiği metinlerin kolaylıkla işlenmesini sağlayacak</div><div>araçlar geliştirmek. Örneğin bir kuruluşun (bir banka, silahlı kuvvetler,</div><div>Facebook, internet yazıları) bütün iletişimlerinin izlenmesi ve istenen</div><div>sorulara cevap bulunması. Bu işlemin yüzlerce seçenek oluşturan anahtar</div><div>kelimeler yerine daha sınırlı anlamsal şekilde ve çabuk gerçekleştirilmesi.</div><div>Nihai hedef, bir insanın zihinsel işleyişine benzer yaklaşımlarla OTOMATİK ANLAMA.</div></div><br /></div><div><br style="background-color: white; color: #1d2228; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;" /></div>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-88380959995073991182020-12-08T06:05:00.007-08:002020-12-08T06:05:45.607-08:00LANGANA-T artık okuduğunu anlamaya başladı<p>İyi haber!</p><p>LANAGANA-T aşağıdaki yazıyı okuyup yazının ne olduğunu anlayabiliyor.</p><p><br /></p><p>-------------------------------------</p><p> Deniz Yıldızının Hikayesi</p><p> Bir adam sabaha karşı okyanus kenarında yürüyormuş. Birden binlerce deniz yıldızının karaya vurduğunu görmüş. Daha da yaklaştığı zaman bir çocuk fark etmiş. Çocuk deniz yıldızlarını tek tek alarak denize geri götürüyormuş.</p><p> Adam çocuğa yaklaşarak sormuş:</p><p> -Bu deniz yıldızlarını neden denize geri atıyorsun? </p><p> Çocuk cevap vermiş:</p><p> -Güneş yükseliyor. Birazdan sular çekilecek ve bu deniz yıldızları susuzluktan ölecekler.</p><p> Adam bu duruma şaşırmış:</p><p> -Sahil çok uzun ve çok fazla deniz yıldızı var. Hepsini kurtaramazsın. Ne fark eder ki?</p><p> Çocuk adamı dinlemiş. Daha sonra sahilden bir deniz yıldızı daha alarak denize bırakmış. </p><p> Sonra adama dönerek:</p><p> -Bak görüyor musun bu deniz yıldızı için fark etti demiş.</p><p>---------------------------------------</p><p>Bu yazı ne anlatıyor?</p><p>Bu hikaye bir adam ile bir çocuk arasında bir deniz yıldızı hakkında geçen bir konuşmayı anlatıyor.</p><p>Aslında bundan ötesini de anlaması mümkün fakat bu biraz daha çaba gerektiriyor. </p><p>Ali R+</p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-38874459687831889542020-09-28T07:21:00.010-07:002020-09-28T07:28:13.748-07:00Langana-T’de Önemli Bir Adım<p> </p><p align="center" class="MsoNormal" style="margin-bottom: 0in; text-align: center;"><b><span style="color: red; font-size: 14pt; line-height: 115%;">Langana-T’de Önemli Bir Adım</span></b></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Langana-T
başlığı altında topladığım Türkçe NLP çalışmamın CORPUS (referans metinler
dağarcığı) oluşturma çalışmam 1 milyon kelimeyi aştı.<span style="mso-spacerun: yes;"> </span>Langana-T CORPUS’u çeşitli konular ve
dönemler Türkçesi içeren 16 kitaptan oluşuyor. Kitapların listesi aşağıda...</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Langana-T
çerçevesinde yaptığım Türkçe parserın kelime morfolojisi parserında ise başarı
oranım %99.98’in üzerinde.<span style="mso-spacerun: yes;"> </span>Hata oranı
ise % 0.18 yani binde 2’nin altında.<span style="mso-spacerun: yes;"> </span>Bu
oran çok eski dil kullanan Tanpınar’ın Saatleri Ayarlama Enstitüsünde bile
%0.44 yani binde 5’in altında*.</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Çalışmamın
bu aşamasında kelime morfolojisi parserını iyileştirme işlemini biraz
yavaşlatarak cümle morfolojisi için benzer bir başarı yüzdesi yakalama çabasına
başlayacağım.<span style="mso-spacerun: yes;"> </span>Öncelikle isim, sıfat,
zarf gruplamalarının belirlenmesi, daha sonra özne-fiil belirlenmesi ve cümle
yapısı kalıplarının dağarcığının oluşturulması...</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Yaptığım
işin kalitesi daha da yükseltilebilir fakat bu tek kişinin bunların hepsini
birlikte yapması açısından imkansız.<span style="mso-spacerun: yes;"> </span>Bir
TUBITAK desteği alabilmem ve ekip kurabilmem için elinden gelenlerin yardımcı
olması dileğimi saygıyla sunarım**.</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;">Ali Riza SARAL</p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="margin-bottom: 0in;">Dip notlar:</p>
<p class="MsoNormal" style="margin-bottom: 0in;">**Geliştirmeyi
hedeflediğim sistem şu amaçlarla kullanılabilir:</p>
<p class="MsoListParagraphCxSpFirst" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"></p><ul style="text-align: left;"><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Konu analizi</li><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Çeşitli çok detaylı arama
işlemleri</li><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Yüksek duyarlıklı sentiment
analizi</li><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Metin karşılaştırma</li><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Bir referans metne göre
otomatik soru cevaplama</li><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Türkçe İngilizce tercüme</li><li><span style="mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Log vb uzun yazı
metinlerinin güvenlik ve kanun uygulaması için akıllı taranması </li></ul><!--[if !supportLists]--><o:p></o:p><p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoListParagraphCxSpLast" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -0.25in;"><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">*Sistemin bilmediği
bir kelime ile karşılaşması durumunda:<o:p></o:p></p>
<p class="MsoListParagraphCxSpFirst" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"></p><ul style="text-align: left;"><li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Online bir uygulama durumunda
kullanıcıya sorarak </li><li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Offline ise %0.2 olasılık
90bin kelimelik bir kitapta 180 kelime eder.<span style="mso-spacerun: yes;">
</span>Bu ise birkaç saatlik tek kişinin yapabileceği bir düzenleme.</li></ul><div><div>İnceMemed2<span style="white-space: pre;"> </span>108000<span style="white-space: pre;"> </span>26422<span style="white-space: pre;"> </span>% 0.26?</div><div>İnceMemed1<span style="white-space: pre;"> </span> 86000<span style="white-space: pre;"> </span>21425<span style="white-space: pre;"> </span>% 0.62</div><div>İkiŞehir<span style="white-space: pre;"> </span> 74000<span style="white-space: pre;"> </span>25608<span style="white-space: pre;"> </span>% 0.66</div><div>Hawking<span style="white-space: pre;"> </span> 42000<span style="white-space: pre;"> </span>12335<span style="white-space: pre;"> </span>% 0.88</div><div>Utopia<span style="white-space: pre;"> </span> 51000<span style="white-space: pre;"> </span>18462<span style="white-space: pre;"> </span>% 0.41</div><div>Masumiyet<span style="white-space: pre;"> </span>141000<span style="white-space: pre;"> </span>35430<span style="white-space: pre;"> </span>% 0.54</div><div>İhtiyarBalıkçı<span style="white-space: pre;"> </span> 49000<span style="white-space: pre;"> </span> 6830<span style="white-space: pre;"> </span>% 0.61</div><div>GarpCephesi<span style="white-space: pre;"> </span> 43000<span style="white-space: pre;"> </span>17251<span style="white-space: pre;"> </span>% 0.61</div><div>AdımKırmızı<span style="white-space: pre;"> </span>120000 <span style="white-space: pre;"> </span>32300 <span style="white-space: pre;"> </span>% 0.47</div><div>1984<span style="white-space: pre;"> </span> 68000<span style="white-space: pre;"> </span>23068<span style="white-space: pre;"> </span>% 0.51</div><div>-------------------------</div><div> <span style="white-space: pre;"> </span>757000</div><div><span style="white-space: pre;"> </span>#words<span style="white-space: pre;"> </span>#distinct #NOT FOUND<span style="white-space: pre;"> </span>#distinct</div><div><span style="white-space: pre;"> </span>words<span style="white-space: pre;"> </span> words<span style="white-space: pre;"> </span>roots</div><div><br /></div><div>Yüzüklerin_Efendisi</div><div>Sineklerin_Tanrısı 51759<span style="white-space: pre;"> </span>15204<span style="white-space: pre;"> </span>% 0.19</div><div>Savaş_Sanatı_Tzu<span style="white-space: pre;"> </span>31548<span style="white-space: pre;"> </span>11847<span style="white-space: pre;"> </span>% 0.84 (% 0.29 typing mistakes removed)</div><div>Saatler_Tanpınar<span style="white-space: pre;"> </span>92382<span style="white-space: pre;"> </span>26135<span style="white-space: pre;"> </span>% 0.44 (old language ... 3dots char mistake)</div><div>insanNeileYaşarTolstoy<span style="white-space: pre;"> </span>18093<span style="white-space: pre;"> </span> 8775<span style="white-space: pre;"> </span>% 0.27</div><div>Huzur_Tanpınar</div><div>Gulliverin_Gezileri<span style="white-space: pre;"> </span>72409<span style="white-space: pre;"> </span>23408<span style="white-space: pre;"> </span>% 0.45 (% 0.18 imaginary beings etc. removed)</div><div>DokuzuncuHariciye<span style="white-space: pre;"> </span>17747 <span style="white-space: pre;"> </span> 8192<span style="white-space: pre;"> </span>% 0.78 (old language)<span style="white-space: pre;"> </span></div><div>-------------------------------</div><div> <span style="white-space: pre;"> </span>283,938</div><div><span style="white-space: pre;"> </span>#words<span style="white-space: pre;"> </span>#distinct #NOT FOUND<span style="white-space: pre;"> </span>#distinct</div><div><span style="white-space: pre;"> </span>words<span style="white-space: pre;"> </span> words<span style="white-space: pre;"> </span>roots</div></div><!--[if !supportLists]--><o:p></o:p><p></p>
<p class="MsoListParagraphCxSpLast" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><o:p></o:p></p>Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-87160195833383117392020-08-01T20:14:00.020-07:002020-08-01T21:01:35.930-07:00LANGANAt de Son Durum <p align="center" class="MsoNormal" style="margin-bottom: 0in; text-align: center;"><b><span style="color: #c00000; font-size: 14pt; line-height: 115%;">LANGANAt'de Son Durum<o:p></o:p></span></b></p>
<p align="center" class="MsoNormal" style="margin-bottom: 0in; text-align: center;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">State of the Art at LANGANAt morphological
parser<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Geçmişte bir
İngilizce - Türkçe tercüme motoru geliştirme çabalarımı destekleyen herkese
teşekkür etmeyi bir borç bilirim.<span style="mso-spacerun: yes;">
</span>Malesef, ben işimi bitirmeden önce GOOGLE yeni ber sürüm çıkarda ve ben
girişimimi durdurmak zorunda kaldım.<span style="mso-spacerun: yes;">
</span>TUBITAK ta bu konuya ilgi gösterebilecek olgunluğa sahip değildi.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">I
would like to thank all who supported my previous efforts to produce a high
quality Englih to Turkish language translator.<span style="mso-spacerun: yes;">
</span>Unfortunately, GOOGLE released a new version before I finished my work
and I had to stop that endeavour.<span style="mso-spacerun: yes;">
</span>TUBITAK was not able to get interested in that subject matter either.<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Onun yerine,
bir çok amaçla kullanılabilecek Türkçe morfolojik dil parçalayıcı üzerinde çalışmaya
başladım.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">Instead
I began to work on a Turkish morphological language parser which can be used
for various purposes.<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Bir
morfolojik parçalayıcı kelimeleri kök ve olası eklerine ayırır.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Örneğin:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">gidiyorum<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">gitmek +
iyor + um<span style="mso-spacerun: yes;"> </span>şimdiki zaman 1. şahıs
(continuous tense 1st person)<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">A
morphological parser parses words to their root and possible extensions.<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">For
example, the word 'going' is parsed as:<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">to
go + ing continuous tense or gerund <o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Bir
morfolojik parçalayıcı çeşitli amaçlarla kullanılabilir:<o:p></o:p></p>
<p class="MsoListParagraphCxSpFirst" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">1-<span style="font: 7pt "times new roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Konu analizi<o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">2-<span style="font: 7pt "times new roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Çeşitli çok detayl ı arama
işlemleri<o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">3-<span style="font: 7pt "times new roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Yüksek duyarlıklı sentiment
analizi<o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">4-<span style="font: 7pt "times new roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Metin karşılaştırma<o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">5-<span style="font: 7pt "times new roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Bir referans metne göre
otomatik soru cevaplama<o:p></o:p></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">6-<span style="font: 7pt "times new roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Türkçe İngilizce tercüme</p><p class="MsoListParagraphCxSpLast" style="margin-bottom: 0in; mso-add-space: auto;"><o:p>Log vb uzun yazı metinlerinin güvenlik ve kanun uygulaması için akıllı taranması </o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">A
morphological parser can be used for making:<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">1-
Subject analysis<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">2-
Various types of sophisticated search<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">3-
High precision Sentiment analysis<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">4-
Text compare<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">5-
Automatic question answering based on a reference text<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">6-
Translation<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10.0pt; line-height: 115%; mso-themecolor: text2;">7- Scanning
of large texts such as logs for security and law enforcement</span><o:p></o:p></i></p>
<p class="MsoNormal" style="margin-bottom: 0in;">Yapay Sinir
Ağları teknolojisi ile çoklu ve karışık cümleler yüksek duyarlılıkla işlenememektedir.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;">%99.5 ‘ten
daha başarılı bir kural tabanlı yaklaşım gereklidir.<span style="mso-spacerun: yes;"> </span>LANAGANt morfolojik parçalayıcı bu yönde ilk
adımdır.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">High
precision for multiple and complex sentences can not be achieved with Neural
Networks.<span style="mso-spacerun: yes;"> </span>A rule based approach with
higher than %99.5 percent is necessary.<span style="mso-spacerun: yes;">
</span>LANGANAt morphological parser is the first step in this direction.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;">Türkçe
kelimeleri güvenilir şekilde parçalamak için gerekli kuralları çıkartacak bir
corpus 8metinler dağarcığı) en azından 1 milyon kelimeden oluşabilir.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">A
corpus for producing the reliable rules to parse Turkish words is probably more
than 1 million words. <o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p>Metin
dağarcığının birleşimi de önemlidir.
Eğer metinler belirli bir konu ya da ortamdan geliyorsa parçalayıcının
güvenilirliği azalmaktadır. LANGANAt
çeşitli yazarlara ait 15’in üzerinde edebi kitaba dayanacak. Yazarlar arasındaki dil farkı
bileparçalayıcının öğrenmesini ve güvenilirliğini etkileyebilmektedir.</p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">The
composure of the corpus is also important.
If texts come from a certain subject area or medium such as Internet the
reliability of the parser descreases. LANGANAt uses more than 15 pieces of
literature belonging to various writers.
Even the language difference between writers effects the learning and the
reliability of the parser.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Test birden
çok alanda yapılmalıdır.<o:p></o:p></p><p class="MsoListParagraphCxSpFirst" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]-->1-<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span><!--[endif]--><span dir="LTR"></span>Bulunmayan kelime sayısı<o:p></o:p></p><p class="MsoListParagraphCxSpLast" style="margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -0.25in;"><!--[if !supportLists]-->2-<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span><!--[endif]--><span dir="LTR"></span>Parçalanan fakat küçük
hatalar içeren kelime sayısı<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">Testing
has to be done in more than one areas. <o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">1-
# of words not found<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">2-
# of words parsed but with minor extension mistakes<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Test işlemi
yeteri kadar büyük metinler üzerinde yapılmalıdır. Ben 50 bin ile 120 bin kelime içeren metinler
kullandım.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">Testing
has to be done with large enough texts.
I used 50 thousand to 120 thousandwords large texts.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">LANGANt
bulunmayan kelime sayısı cinsinden %99.5-6 başarılı oldu. Binde 4-5 hatanın yarısı yazar tarafından
kullanılan özel kelimeler ve yanlış yazım vb.’den kaynaklanıyor.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="font-size: 10pt; line-height: 115%;">LANGANAt is %99.5-6 succesful in # of
words not found is approximately. Half
of this error comes from the special words used by the author and misspellings
etc.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">LANAGANAt 49
bin kelimelik bir test metninde Parçalanan fakat küçük hatalar içeren kelime
sayısı cinsinden % 95-98 arasında bir başarı sağladı.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">LANGANAt
is %95-98 succesful in # of words parsed but with minor extension mistakes.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Son bir söz,
metin parçalayıcılar veya tercüme motorları %85 gibi başarı sonuçları ilan
etmekle kalmayıp ilgili test sonuçlarını da açıklamalıdır.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">Last
but not the least, text parsers or translators should present the test data instead
of indicating %85 percents success, very doubtful indeed.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">LANGANt has
completed more than 430 thousand words<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">İnceMemed2 108000 26422<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">İnceMemed1 86000 21425<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">İkiŞehir 49000 25608<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Hawking 42000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Utopia 51000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">
</p><p class="MsoNormal" style="margin-bottom: 0in;">Masumiyet 141000 35430<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">İhtiyarBalıkçı 49000
6830<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">GarpCephesi 43000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">AdımKırmızı 120000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">1984 68000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">-------------------------<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"> 757000<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">İlk sütun
kitap içindeki kelime sayısını belirtir.
İkinci sütun Farklı kelime sayısını belirtir, aynı kök fakat farklı
ekler dahil.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">The
first column indicates corpus words ready to be processed. The
second column indicates the number of distinct words that may have same root
but different extensions.<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">There will
be a 250 tousand words testing data that has to be prepared.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Yaklaşık 250
bin kelimelik bir corpus arttırımı yapacağım.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">Bu çalışma
çok bu aşamada yüksek bir teknoloji içermese de büyük bir emek zorunlu.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">This
is a not very high tech but highly reliable approach that requires a lot of
labour. <o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">İki Şehirin Hikayesi ile ilgil yaptığım çalışmanın
sonuçlarına sourceforge'tan ulaşabilirsiniz.<o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><i><span style="color: #1f497d; font-size: 10pt; line-height: 115%; mso-themecolor: text2;">You
can reach the outputs of my work on İki Şehrin Hikayesi at sourceforge:<o:p></o:p></span></i></p><p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><p class="MsoNormal" style="margin-bottom: 0in;">
</p><p class="MsoNormal" style="margin-bottom: 0in;"><a href="https://sourceforge.net/projects/turkishlanguageparser/files/iki__sehirin_hikayesi/">https://sourceforge.net/projects/turkishlanguageparser/files/iki__sehirin_hikayesi/</a><o:p></o:p></p><p class="MsoNormal" style="margin-bottom: 0in;"><br /></p>
<p class="MsoNormal" style="margin-bottom: 0in;"><o:p> </o:p></p><br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-72133463467377333882020-03-12T07:05:00.005-07:002020-08-01T21:02:59.573-07:00A Simple Algorithm for Automatic Answering<br />
<div align="center" class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;">
<b><span style="color: red; font-size: 16.0pt; line-height: 115%;">A Simple Algorithm for Automatic Answering<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
First of all
a morphological and syntactical parse of the text must be done.<span style="mso-spacerun: yes;"> </span>The parse should also make grammatical
parsing including the subject-object determination.<span style="mso-spacerun: yes;"> </span>I will assume these are done correctly given
the text below.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Ali
Ankara’ya gitti. Ali okula gitti. Ayşe okula gitti. Ali yemek yedi.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
There must
be an episodic memory which keeps the sentences as:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
SentenceNo<span style="mso-spacerun: yes;"> </span>1: Ali Ankara’ya gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Sentence No
2: Ali okula gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Sentence No
3: Ayşe okula gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Sentence No
4: Ali yemek yedi.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
There must
be a semantical memory to which the items in these sentences are attached, such
as Ali, Ayşe, okul, gitmek, etc. as seen in figure 1.<span style="mso-spacerun: yes;"> </span>To these items, their occurence numbers as
they appear in which sentences are attached.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-PNgg4Z6t9us/XmpBWUyeeFI/AAAAAAAABPc/wRQsmlRIGUwHTz-vUTch0cBS4ci9leVBQCLcBGAsYHQ/s1600/auto-answer%2Balgo1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="297" data-original-width="706" height="167" src="https://1.bp.blogspot.com/-PNgg4Z6t9us/XmpBWUyeeFI/AAAAAAAABPc/wRQsmlRIGUwHTz-vUTch0cBS4ci9leVBQCLcBGAsYHQ/s400/auto-answer%2Balgo1.jpg" width="400" /></a></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p><br /></o:p></div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Figure 1.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
This
structure must be built when the reference text is given.<span style="mso-spacerun: yes;"> </span>Afterwards when the question is asked the
question must be parsed similarly as seen in Figure2.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-5Zcj_mR7Jbg/Xmvjng6LnVI/AAAAAAAABPo/KDwHlIBrZ40cHdd68awFnq0P_hiNj6fRACLcBGAsYHQ/s1600/auto-answer%2Balgo2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="269" data-original-width="651" height="165" src="https://1.bp.blogspot.com/-5Zcj_mR7Jbg/Xmvjng6LnVI/AAAAAAAABPo/KDwHlIBrZ40cHdd68awFnq0P_hiNj6fRACLcBGAsYHQ/s400/auto-answer%2Balgo2.jpg" width="400" /></a></div>
Figure 2.</div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The answer
of the question is given from all the possible deepst common child leaves. That
is sentence 1 and 2:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
SentenceNo<span style="mso-spacerun: yes;"> </span>1: Ali Ankara’ya gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Sentence No
2: Ali okula gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
An other
example question:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-K2wayY68uRs/XmvjyrPkVlI/AAAAAAAABPs/R6D9xoo_P78YFrqgAWeZm4AnfCD0r6SlACLcBGAsYHQ/s1600/auto-answer%2Balgo3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="237" data-original-width="665" height="142" src="https://1.bp.blogspot.com/-K2wayY68uRs/XmvjyrPkVlI/AAAAAAAABPs/R6D9xoo_P78YFrqgAWeZm4AnfCD0r6SlACLcBGAsYHQ/s400/auto-answer%2Balgo3.jpg" width="400" /></a></div>
Figure 3.</div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The answer
is sentence 2 and 3, that is:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Sentence No
2: Ali okula gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Sentence No
3: Ayşe okula gitti.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
More
importantly:<span style="mso-spacerun: yes;"> </span>If the semantic tree is
well developed this structure can answer more abstract questions such as:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Kim hareket
etti?<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Ali ne
yaptı?<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Cheers.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Ali Riza
SARAL<o:p></o:p></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-18545722119671012062020-01-30T11:14:00.000-08:002020-01-31T05:51:34.828-08:00LANGANAt: Yaşar Kemal Ince Memed 2 morphologic analysisYaşar Kemal Ince Memed 2 morpholojik analizi<br />
<br />
Cümle sayısı: 15463<br />
Kelime sayısı: 108899<br />
Tekrarlanmamamış Özgün kelime sayısı: 25209<br />
Kelime ortalama tekrarı: 4<br />
Fiil sayısı(aynı fiilin tüm çekimleri dahil): 9254<br />
Fiil kök sayısı(-mak -mek):122<br />
Fiil sayısı(sorunlu olabilir): 113<br />
Zamir sayısı: 261<br />
Zarf sayısı: 805<br />
Sıfat sayısı: 3098<br />
İsim sayısı: 8623<br />
Edat sayısı: 33<br />
Bağlaç sayısı: 55<br />
Ünlem: 15<br />
Özel İsim: 672 ?<br />
NOT FOUND sayısı(sözlükte bulunamayan): 1710<br />
<br />
<a href="https://sourceforge.net/projects/turkishlanguageparser/files/Turkish%20Parser/InceMemed2_MORPHOLOGIC_analysis.txt/download">https://sourceforge.net/projects/turkishlanguageparser/files/Turkish%20Parser/InceMemed2_MORPHOLOGIC_analysis.txt/download</a><br />
<br />
<br />
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-77920344789197073012020-01-04T05:54:00.002-08:002020-01-04T05:54:50.470-08:00Yazılım Mühendislerinin İşe Alımı İnceleme Süreci<br />
<div align="center" class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;">
<b><span style="color: red; font-size: 14.0pt; line-height: 115%;">Yazılım Mühendislerinin İşe Alımı İnceleme Süreci üzerine bazı
Düşünceler<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: white; color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1;">2019 sonlarında uluslararası bir
inceleme şirketi(Vetting Company) ile tanıştım. Hindistan’da bulunan biriyle
interview’um yapıldı.<span style="mso-spacerun: yes;"> </span>Daha sonra LA’de
içlerinde ekip liderininde bulunduğu 6 inceleme elmanı ile birtoplantuya
katıldım.<span style="mso-spacerun: yes;"> </span>Interview içeriği ve yapısı
ile ilgili samimi fikirlerimi onlara sundum. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: white; color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1;">İşte konu ile ilgili görüşlerim.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Kişisel
ortam:<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l2 level1 lfo1; mso-text-indent-alt: -.25in; text-indent: -.5in;">
</div>
<ul>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Programcının kişisel
bilgisayar ortamının nasıl düzenli olduğunu kontrol ediniz.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Gruplama yoğunluğu ve
unsurların kalitesini kontrol ediniz. </li>
</ul>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l2 level1 lfo1; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Daha önce
yapılmış işler:<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l3 level1 lfo2; mso-text-indent-alt: -.25in; text-indent: -.5in;">
</div>
<ul>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Adayın daha önce yapmış
olduğu işleri sorunuz. <span style="mso-spacerun: yes;"> </span></li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Bunların gerçek olup
olmadığını örnekler ve kodlar üzerinde sorular sorarak kontrol ediniz.<span style="mso-spacerun: yes;"> </span></li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>LOC ve istatistik
bilgilerini, bunlar üzerinde kaç kişi çalıştığını ve bitirmek için adayın ne
kadar zamanını aldığını sorunuz.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Kullanılmış dokümantasyon
sistemini ve Yazılım Döngüsünü (Software Lifecycle) sorunuz. Comment’leri ve
diğer belgeleme örneklerini kontrol ediniz.</li>
</ul>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l3 level1 lfo2; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l3 level1 lfo2; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l3 level1 lfo2; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Öğrenme
eğrisi testi:<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l5 level1 lfo3; mso-text-indent-alt: -.25in; text-indent: -.5in;">
</div>
<ul>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Adaya hangi programlama
dillerini kullanmış olduğunu sorunuz.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Aday için en uygunu olmayan
birini seçiniz. </li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Adaydan internet
referanslarından faydalanarak bu dil ile basit bir program yazmasını <span style="mso-spacerun: yes;"> </span>isteyiniz. </li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Ne kadar zaman aldığını ve
ne kadar kaliteli sonuç aldığınızı kontrol ediniz.</li>
</ul>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l5 level1 lfo3; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l5 level1 lfo3; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l5 level1 lfo3; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Hata bulma
yetenek testi:<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l4 level1 lfo4; mso-text-indent-alt: -.25in; text-indent: -.5in;">
</div>
<ul>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Değişen zorluklarda hatalı
programlar hazırlayınız. </li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Adayın bunları çözüp
çözemediğini ve ne kadar zamanda çözdüğünü kontrol ediniz. </li>
</ul>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l4 level1 lfo4; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Kopyalama/Geliştirme
yetenek testi:<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo5; mso-text-indent-alt: -.25in; text-indent: -.5in;">
</div>
<ul>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Sorunlara yaklaşım
biçiminizi yansıtan, şirketinize/projeye ait templateler üretiniz.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span>Adayın bu templateleri
kullanarak küçük bir çözüm üretmesini isteyiniz.</li>
</ul>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo5; mso-text-indent-alt: -.25in; text-indent: -.5in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Test yapma
yetenek testi:<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo6; mso-text-indent-alt: -.25in; text-indent: -.5in;">
</div>
<ul>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-language: TR;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";">
</span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Adayın daha önce kullanmış olduğu bir test sürecini
isteyiniz. <o:p></o:p></span></li>
<li><span style="color: black; font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><span style="mso-list: Ignore;"><span style="font: 7.0pt "Times New Roman";"> </span><span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span dir="LTR"></span><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Verdiğiniz bir program için adayın bir test prosedürü
geliştirmesini isteyiniz.</span><span style="color: black; font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"> <o:p></o:p></span></li>
</ul>
<!--[if !supportLists]--><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-75359156566596951222020-01-02T10:22:00.002-08:002020-01-03T05:23:29.739-08:00Vetting process for recruitment of Software Engineers<div align="center" class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;">
<b><span style="color: red; font-size: 14.0pt; line-height: 115%;">Some ideas on the Vetting process for recruitment of Software
Engineers<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background-color: white; color: #1c1e21; font-family: Helvetica, Arial, sans-serif; font-size: 14px;">Recently I met with an international vetting company. I got an interview with somebody in India and then I attended a meeting with 6 vetting professionals from LA including their leaders. I offered them my sincere views about the interview and its design. Here are my opinions on the subject.</span><br />
<br />
Personal
environment:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<ul>
<li>Check how is
the programmer’s personal computer environment organise.</li>
<li>Check
grouping density and quality of items</li>
</ul>
<o:p></o:p><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Previous
works:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<ul>
<li>Ask for
examples of previous work’s of the candidate.<span style="mso-spacerun: yes;">
</span></li>
<li>Check
whether they are true examples by asking questions about the examples.<span style="mso-spacerun: yes;"> </span></li>
<li>Ask LOC and
other statistics information including how many people has worked on them and
how long did it take them and the specific candidate to finish it.</li>
<li>Ask for the
documentation process and the Software lifecycle used.<span style="mso-spacerun: yes;"> </span>Check the comments and other documentation
examples.</li>
</ul>
<o:p></o:p><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Learning
curve test:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<ul>
<li>Ask the
candidate which programming languages he/she has used.</li>
<li>Choose one
that is not the best for the candidate.</li>
<li>Ask him/her
to write a simple program in that language using internet as a reference.</li>
<li>Check how
long and how good it takes.</li>
</ul>
<o:p></o:p><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Diagnosing
ability test:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<ul>
<li>Produce
faulty programs with varying difficulty.</li>
<li>Check if/how
long the candidate can fix them. </li>
</ul>
<o:p></o:p><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Copying/developing
ability test<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<ul>
<li>Produce
company templates which characterize how your company approaches to specific
problems.</li>
<li>Require the
candidate to develop a small solution using these templates</li>
</ul>
<div>
Testing ability test</div>
<div>
<ul>
<li>Ask for a test process the candidate has used in prev work</li>
<li>Require the candidate to produce a test method for a given program</li>
</ul>
</div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-1498866585905627462019-12-07T23:44:00.000-08:002019-12-07T23:46:57.667-08:00NetBeans RESTful example CustomerDB does notwork<div class="separator" style="clear: both; text-align: center;">
<span style="color: red; font-size: large;"><br /></span></div>
<h3 class="post-title entry-title" itemprop="name" style="background-color: #fff3db; font-family: Georgia, "Times New Roman", sans-serif; font-weight: normal; margin: 0px; padding: 0px; text-align: center;">
<span style="color: red; font-size: large;">NetBeans RESTful example CustomerDB does not work</span></h3>
<br />
<br />
NetBeans 8.1 New Project->Samples->WebServices->REST:CustomerDB(JAVAEE6)
example does not work.<br />
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">1-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>First of all you have to
make sure that the Derby database is working.<o:p></o:p></div>
<div class="MsoNormal">
Select from Services
menu->Databases->jdbc:derby://localhost:1527/sample[app on APP]<o:p></o:p></div>
<div class="MsoNormal">
User = app pwd=app (in my case) (user and pwd must be the
same, just type the uid to pwd)<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">2-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Select from services
Menu->Servers->GlassFish Server and right click->Start<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">3-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>After starting the server
from Projects Menu Clean and Build CustomerDB.<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">4-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Select Deploy customerDB by
rightclick on CustomerDB<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">5-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Select and run
CustomerDB->js->testresbeans.html</div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiutmE-luSGAfG5QWQTbtj_6JWSwgi1LrQNY7RLmHUCna_PSor9k5cr5pgyVjHgNS5r5bLNPvp7UerYcSXiDE1hmoJr9XO_ppPDTGr-vPWI9Cqf4VNdwoZPLfmsoqx1zu3Q5Wr5Iup02KE1/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="337" data-original-width="353" height="381" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiutmE-luSGAfG5QWQTbtj_6JWSwgi1LrQNY7RLmHUCna_PSor9k5cr5pgyVjHgNS5r5bLNPvp7UerYcSXiDE1hmoJr9XO_ppPDTGr-vPWI9Cqf4VNdwoZPLfmsoqx1zu3Q5Wr5Iup02KE1/s400/1.jpg" width="400" /></a></div>
<br />
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">6-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Select RESTful Web
Services->CustomerFacadeREST with rightclick select Test ResourceUri<o:p></o:p></div>
<a href="https://1.bp.blogspot.com/-Jq0OrMyfhoo/XeyoYAcGO7I/AAAAAAAABNA/KpVyV-70w8cKl05BBmUhKbLL-3ZwMPXcwCEwYBhgL/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="384" data-original-width="237" height="400" src="https://1.bp.blogspot.com/-Jq0OrMyfhoo/XeyoYAcGO7I/AAAAAAAABNA/KpVyV-70w8cKl05BBmUhKbLL-3ZwMPXcwCEwYBhgL/s400/2.jpg" width="245" /></a><br />
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">7-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>This means the RESTful side
is working.<span style="mso-spacerun: yes;"> </span>But there is probably
something wrong in the URI.<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">8-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Put an alert before:<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
alert(req); //ARSSSSSSSSSssssssssssssssss<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>if(method == 'POST') {<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>c = this.xhr.post(req, mimetype, params);<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>} else if(method == 'PUT') {<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>c = this.xhr.put(req, mimetype, params);<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>} else if(method == 'GET') {<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>c = this.xhr.get(req);<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>//c = this.xhr.get(req, mimetype);<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>} else if(method == 'DELETE') {<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>c = this.xhr.delete_(req);<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>}<o:p></o:p></div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">9-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Yes, the URI is distorted.<o:p></o:p></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb85PCA_gA2_gTY1aFcS0WsCWzxGvdJuTNvjSdFhI510LeE0XS8GSbiZGiMce-8NkKMg2HNSO0c2WmJ8F1say-ZQqXO2A4EmHN4hTN5jz3PqnL6-yBDxQCaZ20DegTnnrXeT0geS9SS_H_/s1600/3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="364" data-original-width="639" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb85PCA_gA2_gTY1aFcS0WsCWzxGvdJuTNvjSdFhI510LeE0XS8GSbiZGiMce-8NkKMg2HNSO0c2WmJ8F1say-ZQqXO2A4EmHN4hTN5jz3PqnL6-yBDxQCaZ20DegTnnrXeT0geS9SS_H_/s400/3.jpg" width="400" /></a><br />
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">10-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>In order to locate the
mistake:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
var req;<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;">
</span>alert(path);//ARSSSSSSSSSssssssssssssssss<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;">
</span>alert(baseURL);//ARSSSSSSSSSssssssssssssssss<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;">
</span>if( ts.isURL(path) )<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;"> </span>req = path;<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;">
</span>else<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;"> </span>req = baseURL+escape(path);<span style="mso-spacerun: yes;"> </span>// ARSSSSSSSSS<o:p></o:p></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;">
</span>//change url if there are template params<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in;">
<span style="mso-spacerun: yes;">
</span>if(tparams != null) {<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">11-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span dir="LTR"></span>Temporary solution is:<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
var req;<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>alert(path);//ARSSSSSSSSSssssssssssssssss<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>alert(baseURL);//ARSSSSSSSSSssssssssssssssss<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>if( ts.isURL(path) )<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>req = path;<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>else<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>req = path;<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-spacerun: yes;">
</span>//req = baseURL+escape(path);<span style="mso-spacerun: yes;"> </span>//
ARSSSSSSSSS<o:p></o:p></div>
<br />
<a href="https://1.bp.blogspot.com/-dxOTXdQABL4/XeyoZbzDgdI/AAAAAAAABNM/Ilw3oNQnL6YkW9ifEheq0ptFZmofolq3ACEwYBhgL/s1600/4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="345" data-original-width="640" height="215" src="https://1.bp.blogspot.com/-dxOTXdQABL4/XeyoZbzDgdI/AAAAAAAABNM/Ilw3oNQnL6YkW9ifEheq0ptFZmofolq3ACEwYBhgL/s400/4.jpg" width="400" /></a><br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p> </o:p><a href="https://1.bp.blogspot.com/-N8lvgwIt2FY/XeyoZV3cZmI/AAAAAAAABNQ/JDDVf13AUBopWu9N_Iq9TXE4a8NAR1IWQCEwYBhgL/s1600/5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="538" data-original-width="455" height="400" src="https://1.bp.blogspot.com/-N8lvgwIt2FY/XeyoZV3cZmI/AAAAAAAABNQ/JDDVf13AUBopWu9N_Iq9TXE4a8NAR1IWQCEwYBhgL/s400/5.jpg" width="336" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-36428817645574852182019-02-24T11:33:00.002-08:002019-02-24T11:37:34.911-08:00A simple REACT node.js example <span style="color: red;">Create Hello.js REACT script</span><br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
helloAli.js<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
'use
strict';<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
//document.write("Hello
World!");<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
const name =
'Ali Riza SARAL';<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
const
element = &lth1&gtHello from {name}&lt/h1><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ReactDOM.render(<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
element,<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
document.getElementById('root')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
);<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">Create the html that will insert the REACT jscript.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
index4.html<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lt!doctype
html&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lthtml&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lthead&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltmeta charset="utf-8"&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lttitle&gtHello React!&lt/title&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltscript
src="https://unpkg.com/react@16/umd/react.development.js"&gt&lt/script&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltscript
src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"&gt&lt/script&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltscript
src="https://unpkg.com/babel-standalone@6.26.0/babel.js"&gt&lt/script&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lt/head&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltbody&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltdiv id="root"&gt&lt/div&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&ltscript type="text/babel"
src="helloAli.js"&gt&lt/script&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lt/body&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
&lt/html&gt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Create the
server that will display the html.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
var url =
require('url');<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Create a
server<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
http.createServer(
function (request, response) { <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Parse the request containing file name<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
var pathname =
url.parse(request.url).pathname;<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Print the name of the file for which
request is made.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
console.log("Request for " +
pathname + " received.");<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Read the requested file content from file
system<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
fs.readFile(pathname.substr(1), function
(err, data) {<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
if (err) {<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
console.log(err);<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// HTTP Status: 404 : NOT FOUND<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Content Type: text/plain<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
response.writeHead(404,
{'Content-Type': 'text/html'});<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
} else { <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
//Page found <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// HTTP Status: 200 : OK<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Content Type: text/plain<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
response.writeHead(200,
{'Content-Type': 'text/html'}); <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Write the content of the file to
response body<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
response.write(data.toString()); <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
}<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Send the response body <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
response.end();<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
}); <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
}).listen(8081);<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
// Console
will print the message<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
console.log('Server
running at <a href="http://127.0.0.1:8081/">http://127.0.0.1:8081/</a>');<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">Run procedure in the same library of all the above:<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: red; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">1-<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span dir="LTR"></span><span style="color: red;">Start
the server with<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="color: red;">Node server<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: red; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">2-<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span dir="LTR"></span><span style="color: red;">Open
a browser<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: red; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">3-<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span dir="LTR"></span><span style="color: red;">Run
the REACT through html<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<a href="http://127.0.0.1:8081/index4.html">http://127.0.0.1:8081/index4.html</a><o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="color: red;">Notes: You do not have to use the node.js server given here. Any server Tomcat, Glassfish will work OK.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span><script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<o:p></o:p>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<body><o:p></o:p></body></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span><br />
<div id="root">
</div>
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span><script src="helloAli.js" type="text/babel"></script><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<o:p></o:p>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-59861877014482091082019-02-19T06:49:00.002-08:002019-02-19T06:49:09.554-08:00A short note on the Agile methods<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: red; font-size: 24.0pt; line-height: 115%;">Agile(Çevik) yöntemler
Üzerine Kısa Bir Not<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">“Business
people and developers must work together daily throughout the project.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">İş
süreçlerinin sahipleri ve yazılımcılar proje boyunca her gün birlikte
çalışmalıdırlar”.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">Bu
madde bazı durumlarda Agile yöntemlerin uygulanmasını imkansız kılabilir.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">Eğer
müşteri tarafında sorunsuz bir ilgi ve destek yok ise Agile yöntemlerin
uygulanması bir kaosa neden olabilir.<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">Ayrıca
müşteri isteklerinin tutarlı ve süreklilik taşıyan niteliklerde olması projenin
başarısını doğrudan etkiler.<span style="mso-spacerun: yes;"> </span>“İki tane
hava trafik kontrolörünün olduğu yerde 3 tane görüş vardır”.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">“Değişen
gereksinimler yazılım sürecinin son aşamalarında bile kabul edilmelidir.<br />
Çevik süreçler değişimi müşterinin rekabet avantajı için kullanır.”<span style="mso-spacerun: yes;"> </span>Bunu her projede uygulamak mümkün
olmayabilir.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">“Çalışan
yazılım, tercihen kısa zaman aralıkları belirlenerek birkaç haftada ya da
birkaç ayda bir düzenli olarak müşteriye sunulmalıdır.”<span style="mso-spacerun: yes;"> </span>Bu madde yalnız belirli bir büyüklüğe kadar
ya da projenin sonuna doğru geçerli olabilir.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">Kullanıcı
gereksinimleri(user requirements) bütünlük ve doğruluk arzetmek zorunda
değildir.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">Kullanıcı
gereksinimlerindeki eksikler ya da gözükmeyen yapısal gereksinimler yazılım
gereksinimleri(software requirements) ile tamamlanır.<span style="mso-spacerun: yes;"> </span>Kullanıcının yapısal teknikleri bilmesi
mümkün değildir.<span style="mso-spacerun: yes;"> </span>Dolayısıyla
kullanıcının rolünü bu kadar abartmak sağlıklı sonuçlar vermeyebilir.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-239486118552429712019-02-01T12:31:00.002-08:002019-02-01T12:31:31.347-08:00how to convert CPU usage to Movidius in Keras<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
I used a simple
Keras example as a starting point.<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="background: white; line-height: 13.2pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-outline-level: 1; vertical-align: baseline;">
<b><i><span style="color: #222222; font-family: "Helvetica","sans-serif"; mso-bidi-font-family: Helvetica; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; mso-font-kerning: 18.0pt;">Develop Your First Neural Network in Python With Keras
Step-By-Step<o:p></o:p></span></i></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<a href="https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/">https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/</a><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">I took the first half of this example:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# MLP for
Pima Indians Dataset Serialize to JSON and HDF5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import Sequential<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import Dense<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import model_from_json<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import numpy<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import os<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# fix random
seed for reproducibility<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
numpy.random.seed(7)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load pima
indians dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
dataset =
numpy.loadtxt("pima-indians-diabetes.csv", delimiter=",")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# split into
input (X) and output (Y) variables<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
X =
dataset[:,0:8]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Y =
dataset[:,8]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# create
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model =
Sequential()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.add(Dense(12,
input_dim=8, kernel_initializer='uniform', activation='relu'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.add(Dense(8,
kernel_initializer='uniform', activation='relu'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.add(Dense(1,
kernel_initializer='uniform', activation='sigmoid'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Compile
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.compile(loss='binary_crossentropy',
optimizer='adam', metrics=['accuracy'])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Fit the
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.fit(X,
Y, epochs=150, batch_size=10, verbose=0)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
x=numpy.array([[0.42030057,
0.78084083, 0.76165254, 0.19794683, 0.78010274, 0.24512312, 0.17131911,
0.03071891]])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print(x)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
yy=model.predict(x,
batch_size=None, verbose=0, steps=None)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print(yy)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">and I added prediction stuff:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
x=numpy.array([[0.42030057,
0.78084083, 0.76165254, 0.19794683, 0.78010274, 0.24512312, 0.17131911,
0.03071891]])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print(x)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
yy=model.predict(x,
batch_size=None, verbose=0, steps=None)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print(yy)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">the output follows:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
runfile('C:/Users/ars/.spyder-py3/ars-test/keras_first_network.py',
wdir='C:/Users/ars/.spyder-py3/ars-test')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
768/768
[==============================] - 0s 13us/step<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
acc: 79.30%<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
[[0.42030057
0.78084083 0.76165254 0.19794683 0.78010274 0.24512312<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>0.17131911 0.03071891]]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
[[0.00283898]]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">This was all done with Anaconda using Keras.<span style="mso-spacerun: yes;"> </span>I put this to make a comparison later on.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">pimasARS.py is the same as the Keras version.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# MLP for
Pima Indians Dataset Serialize to JSON and HDF5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import Sequential<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import Dense<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import model_from_json<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import numpy<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import os<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# fix random
seed for reproducibility<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
numpy.random.seed(7)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load pima
indians dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
dataset =
numpy.loadtxt("pima-indians-diabetes.csv", delimiter=",")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# split into
input (X) and output (Y) variables<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
X =
dataset[:,0:8]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Y =
dataset[:,8]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# create
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model =
Sequential()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.add(Dense(12,
input_dim=8, kernel_initializer='uniform', activation='relu'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.add(Dense(8,
kernel_initializer='uniform', activation='relu'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.add(Dense(1,
kernel_initializer='uniform', activation='sigmoid'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Compile
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.compile(loss='binary_crossentropy',
optimizer='adam', metrics=['accuracy'])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Fit the
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.fit(X,
Y, epochs=150, batch_size=10, verbose=0)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# evaluate
the model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
scores =
model.evaluate(X, Y, verbose=0)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print("%s:
%.2f%%" % (model.metrics_names[1], scores[1]*100))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">but it saves the model to Keras model files JSON and HDF5.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# serialize
model to JSON<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model_json =
model.to_json()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
with
open("model.json", "w") as json_file:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>json_file.write(model_json)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# serialize
weights to HDF5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.save_weights("model.h5")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print("Saved
model to disk")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">Movidius needs to work with TensorFlow<span style="mso-spacerun: yes;"> </span>graph files.<span style="mso-spacerun: yes;">
</span>So I used <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">Convert-pimas file from<o:p></o:p></span></div>
<h1 style="background: white; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 15.0pt;">
<i><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 11.0pt;">How to run Keras model on Movidius neural compute stick<o:p></o:p></span></i></h1>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;"><a href="https://github.com/Tony607/keras_mnist">https://github.com/Tony607/keras_mnist</a><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">convert-pimas.py<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import model_from_json<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from keras
import backend as K<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
tensorflow as tf<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import model_from_json<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from keras
import backend as K<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
tensorflow as tf<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model_file =
"model.json"<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
weights_file
= "model.h5"<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
with
open(model_file, "r") as file:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>config = file.read()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
K.set_learning_phase(0)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model =
model_from_json(config)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.load_weights(weights_file)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
saver =
tf.train.Saver()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
sess =
K.get_session()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
saver.save(sess,
"./TF_Model/tf_model")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
fw =
tf.summary.FileWriter('logs', sess.graph)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
fw.close()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model_file =
"model.json"<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
weights_file
= "model.h5"<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
with
open(model_file, "r") as file:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>config = file.read()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
K.set_learning_phase(0)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model =
model_from_json(config)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.load_weights(weights_file)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
saver =
tf.train.Saver()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
sess =
K.get_session()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
saver.save(sess,
"./TF_Model/tf_model")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
fw =
tf.summary.FileWriter('logs', sess.graph)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
fw.close()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">if you notice, this program does not produce a TensorFlow<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">graph file.<span style="mso-spacerun: yes;"> </span>This job
is done with the statement below<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">which you can find in the Makefile.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
.PHONY:
compile<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
compile:
weights<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>test -f graph || ${NCCOMPILE} -s
12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG}<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">mvNCCompile -s 12 TF_Model/tf_model.meta -in=dense_1_input
-on=dense_3/Sigmoid<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">-in and –on parameters can be found in the logs/events.out.tfevents.1549033801.ars
files<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">After this we have to prepare the Movidius stick, open, load
etc.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">İn the predict-pimas.py.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#!/usr/bin/env
python3.5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# [NCSDK2
API](https://movidius.github.io/ncsdk/ncapi/ncapi2/py_api/readme.html)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from mvnc
import mvncapi as mvnc<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from keras
import backend as K<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import numpy<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import cv2<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Using NCS
Predict<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# set the
logging level for the NC API<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#
mvnc.global_set_option(mvnc.GlobalOption.RW_LOG_LEVEL, 0)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# get a list
of names for all the devices plugged into the system<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
devices =
mvnc.enumerate_devices()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
if
len(devices) == 0:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>print('No devices found')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>quit()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# get the
first NCS device by its name.<span style="mso-spacerun: yes;"> </span>For this
program we will always open the first NCS device.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
dev =
mvnc.Device(devices[0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# try to
open the device.<span style="mso-spacerun: yes;"> </span>this will throw an
exception if someone else has it open already<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
try:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>dev.open()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
except:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>print("Error - Could not open NCS
device.")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>quit()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">Once Movidius stick is ready we have to load the graph to it <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Read a
compiled network graph from file (set the graph_filepath correctly for your
graph file)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
with
open("graph", mode='rb') as f:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>graphFileBuff = f.read()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
graph =
mvnc.Graph('graph1')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">then we have to put in the test data (the same as the complete
Keras version)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Allocate the
graph on the device and create input and output Fifos<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
in_fifo,
out_fifo = graph.allocate_with_fifos(dev, graphFileBuff)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
testInput=numpy.array([[0.42030057,
0.78084083, 0.76165254, 0.19794683, 0.78010274, 0.24512312, 0.17131911,
0.03071891]])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Write the
input to the input_fifo buffer and queue an inference in one call<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#graph.queue_inference_with_fifo_elem(in_fifo,
out_fifo, testInput.astype('float32'), 'user object')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
graph.queue_inference_with_fifo_elem(in_fifo,
out_fifo, testInput.astype('float32'),'object1')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">read the output and print<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Read the
result to the output Fifo<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
output,
userobj = out_fifo.read_elem()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# Deallocate
and destroy the fifo and graph handles, close the device, and destroy the
device handle<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
try:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>in_fifo.destroy()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>out_fifo.destroy()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>graph.destroy()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>dev.close()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>dev.destroy()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
except:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>print("Error - could not close/destroy
Graph/NCS device.")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>quit()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#print("NCS
\r\n", output, '\r\nPredicted:',output.argmax())<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print(output)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">The output :<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
arsaral@ars:~/ncsdk/ncappzoo/apps/pimas$
python3 <span style="mso-spacerun: yes;"> </span>predict-pimas.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Using
TensorFlow backend.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py:936:
DeprecationWarning: builtin type EagerTensor has no __module__ attribute<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>EagerTensor = c_api.TFE_Py_InitEagerTensor(_EagerTensorBase)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/tf_inspect.py:75:
DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature()
instead<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>return _inspect.getargspec(target)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
/usr/local/lib/python3.5/dist-packages/mvnc/mvncapi.py:416:
DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves
surprisingly on unicode inputs. Use frombuffer instead<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>tensor = numpy.fromstring(tensor.raw,
dtype=numpy.float32)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
[0.00512314]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
arsaral@ars:~/ncsdk/ncappzoo/apps/pimas$<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">A Keras only test output: [0.00283898]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: red;">A Movidius test output:<span style="mso-spacerun: yes;">
</span>[0.00512314]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-90504511822659669192019-01-28T08:18:00.003-08:002019-01-28T08:18:49.678-08:00Implementation - How to Develop a Neural Machine Translation System from Scratch<br />
<div class="MsoNormal" style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 13.2pt; mso-outline-level: 1; vertical-align: baseline;">
<b><span style="color: #222222; font-family: "Helvetica","sans-serif"; font-size: 21.0pt; mso-bidi-font-family: Helvetica; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR; mso-font-kerning: 18.0pt;">IMPLEMENTATION: How to Develop a Neural Machine
Translation System from Scratch<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
This is an
implementation of Jason BROWNLEE’s program:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<a href="https://machinelearningmastery.com/develop-neural-machine-translation-system-keras/">https://machinelearningmastery.com/develop-neural-machine-translation-system-keras/</a><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
You can view
the results at the bottom.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Trans.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# -*-
coding: utf-8 -*-<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Created on
Sat Dec<span style="mso-spacerun: yes;"> </span>8 22:37:54 2018<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
@author: Jason
BROWNLEE<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import os;
os.environ['KERAS_BACKEND'] = 'theano'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
string<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import re<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from pickle
import dump<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
unicodedata import normalize<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from numpy
import array<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load doc
into memory<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
load_doc(filename):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># open the file as read only<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>file = open(filename, mode='rt',
encoding='utf-8')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># read all text<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>text = file.read()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># close the file<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>file.close()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return text<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# split a
loaded document into sentences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
to_pairs(doc):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>lines = doc.strip().split('\n')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>pairs = [line.split('\t') for
line in<span style="mso-spacerun: yes;"> </span>lines]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return pairs<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# clean a
list of lines<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
clean_pairs(lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>cleaned = list()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># prepare regex for char
filtering<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>re_print = re.compile('[^%s]' %
re.escape(string.printable))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># prepare translation table for
removing punctuation<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>table = str.maketrans('', '',
string.punctuation)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>for pair in lines:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>clean_pair =
list()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>for line in pair:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
normalize unicode characters<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= normalize('NFD', line).encode('ascii', 'ignore')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= line.decode('UTF-8')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
tokenize on white space<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= line.split()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
convert to lowercase<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= [word.lower() for word in line]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
remove punctuation from each token<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= [word.translate(table) for word in line]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
remove non-printable chars form each token<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= [re_print.sub('', w) for w in line]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
remove tokens with numbers in them<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>line
= [word for word in line if word.isalpha()]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>#
store as string<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>clean_pair.append('
'.join(line))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>cleaned.append(clean_pair)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return array(cleaned)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# save a
list of clean sentences to file<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
save_clean_data(sentences, filename):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>dump(sentences, open(filename,
'wb'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('Saved: %s' % filename)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load
dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
filename =
'deu.txt'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
doc =
load_doc(filename)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# split into
english-german pairs<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
pairs =
to_pairs(doc)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# clean
sentences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
clean_pairs
= clean_pairs(pairs)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# save clean
pairs to file<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
save_clean_data(clean_pairs,
'english-german.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# spot check<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
for i in
range(10):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('[%s] => [%s]' %
(clean_pairs[i,0], clean_pairs[i,1]))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
-----------------------------------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Trans2.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# -*-
coding: utf-8 -*-<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Created on
Sat Dec<span style="mso-spacerun: yes;"> </span>8 23:02:11 2018<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
@author: ars<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import os;
os.environ['KERAS_BACKEND'] = 'theano'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from pickle
import load<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from pickle
import dump<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
numpy.random import rand<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
numpy.random import shuffle<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load a
clean dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
load_clean_sentences(filename):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return load(open(filename,
'rb'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# save a
list of clean sentences to file<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
save_clean_data(sentences, filename):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>dump(sentences, open(filename,
'wb'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('Saved: %s' % filename)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load
dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
raw_dataset
= load_clean_sentences('english-german.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# reduce
dataset size<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
n_sentences
= 10000<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
dataset =
raw_dataset[:n_sentences, :]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# random
shuffle<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
shuffle(dataset)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# split into
train/test<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
train, test
= dataset[:9000], dataset[9000:]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# save<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
save_clean_data(dataset,
'english-german-both.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
save_clean_data(train,
'english-german-train.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
save_clean_data(test,
'english-german-test.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Trans3.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# -*-
coding: utf-8 -*-<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Created on
Sat Dec<span style="mso-spacerun: yes;"> </span>8 23:05:25 2018<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
@author: ars<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import os;
os.environ['KERAS_BACKEND'] = 'theano'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#os.environ["PATH"]
+= os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from pickle
import load<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from numpy
import array<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.preprocessing.text import Tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.preprocessing.sequence import pad_sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.utils import to_categorical<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.utils.vis_utils import plot_model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import Sequential<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import LSTM<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import Dense<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import Embedding<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import RepeatVector<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.layers import TimeDistributed<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.callbacks import ModelCheckpoint<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
theano; <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#print(theano.config)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
theano.tensor;<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
theano.config.cxx="C:\\Users\\ars\\Anaconda3\\Library\\mingw-w64\\bin\\g++.exe"<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load a
clean dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
load_clean_sentences(filename):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return load(open(filename,
'rb'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# fit a
tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
create_tokenizer(lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>tokenizer = Tokenizer()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>tokenizer.fit_on_texts(lines)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# max
sentence length<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
max_length(lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return max(len(line.split()) for
line in lines)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# encode and
pad sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
encode_sequences(tokenizer, length, lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># integer encode sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>X = tokenizer.texts_to_sequences(lines)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># pad sequences with 0 values<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>X = pad_sequences(X,
maxlen=length, padding='post')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return X<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# one hot
encode target sequence<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
encode_output(sequences, vocab_size):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>ylist = list()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>for sequence in sequences:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>encoded =
to_categorical(sequence, num_classes=vocab_size)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>ylist.append(encoded)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>y = array(ylist)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>y =
y.reshape(sequences.shape[0], sequences.shape[1], vocab_size)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return y<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# define NMT
model (Neural Machine Translation)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
define_model(src_vocab, tar_vocab, src_timesteps, tar_timesteps, n_units):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>model = Sequential()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>model.add(Embedding(src_vocab,
n_units, input_length=src_timesteps, mask_zero=True))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>model.add(LSTM(n_units))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>model.add(RepeatVector(tar_timesteps))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>model.add(LSTM(n_units,
return_sequences=True))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>model.add(TimeDistributed(Dense(tar_vocab,
activation='softmax')))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load
datasets<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
dataset =
load_clean_sentences('english-german-both.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
train =
load_clean_sentences('english-german-train.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test = load_clean_sentences('english-german-test.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
english tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
eng_tokenizer
= create_tokenizer(dataset[:, 0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
eng_vocab_size
= len(eng_tokenizer.word_index) + 1<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
eng_length =
max_length(dataset[:, 0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print('English
Vocabulary Size: %d' % eng_vocab_size)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print('English
Max Length: %d' % (eng_length))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
german tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ger_tokenizer
= create_tokenizer(dataset[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ger_vocab_size
= len(ger_tokenizer.word_index) + 1<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ger_length =
max_length(dataset[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print('German
Vocabulary Size: %d' % ger_vocab_size)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print('German
Max Length: %d' % (ger_length))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
training data<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
trainX =
encode_sequences(ger_tokenizer, ger_length, train[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
trainY =
encode_sequences(eng_tokenizer, eng_length, train[:, 0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
trainY =
encode_output(trainY, eng_vocab_size)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
validation data<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
testX =
encode_sequences(ger_tokenizer, ger_length, test[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
testY =
encode_sequences(eng_tokenizer, eng_length, test[:, 0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
testY =
encode_output(testY, eng_vocab_size)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# define
model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model =
define_model(ger_vocab_size, eng_vocab_size, ger_length, eng_length, 256)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.compile(optimizer='adam',
loss='categorical_crossentropy')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# summarize
defined model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print(model.summary())<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
plot_model(model,
to_file='model.png', show_shapes=True)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# fit model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
filename = 'model.h5'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
checkpoint =
ModelCheckpoint(filename, monitor='val_loss', verbose=1, save_best_only=True,
mode='min')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model.fit(trainX,
trainY, epochs=30, batch_size=64, validation_data=(testX, testY),
callbacks=[checkpoint], verbose=2)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
------------------------------------------------------------------
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Trans4.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# -*-
coding: utf-8 -*-<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Created on
Sun Dec<span style="mso-spacerun: yes;"> </span>9 20:50:52 2018<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
@author: ars<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
"""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import os;
os.environ['KERAS_BACKEND'] = 'theano'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#import os<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#os.environ["PATH"]
+= os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from pickle
import load<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#from numpy
import array<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from numpy
import argmax<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.preprocessing.text import Tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.preprocessing.sequence import pad_sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
keras.models import load_model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from
nltk.translate.bleu_score import corpus_bleu<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#import
theano<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#import
theano.tensor<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#theano.config.cxx=""<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
theano; <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#print(theano.config)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
import
theano.tensor;<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
theano.config.cxx="C:\\Users\\ars\\Anaconda3\\Library\\mingw-w64\\bin\\g++.exe"<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load a
clean dataset<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def load_clean_sentences(filename):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return load(open(filename,
'rb'))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# fit a
tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
create_tokenizer(lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>tokenizer = Tokenizer()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>tokenizer.fit_on_texts(lines)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# max
sentence length<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
max_length(lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return max(len(line.split()) for
line in lines)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# encode and
pad sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
encode_sequences(tokenizer, length, lines):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># integer encode sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>X =
tokenizer.texts_to_sequences(lines)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># pad sequences with 0 values<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>X = pad_sequences(X,
maxlen=length, padding='post')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return X<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# map an
integer to a word<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
word_for_id(integer, tokenizer):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>for word, index in
tokenizer.word_index.items():<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>if index ==
integer:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>return
word<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return None<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# generate
target given source sequence<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
predict_sequence(model, tokenizer, source):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>prediction =
model.predict(source, verbose=0)[0]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>integers = [argmax(vector) for
vector in prediction]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>target = list()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>for i in integers:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>word =
word_for_id(i, tokenizer)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>if word is None:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>break<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>target.append(word)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>return ' '.join(target)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# evaluate
the skill of the model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
def
evaluate_model(model, tokenizer, sources, raw_dataset):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>actual, predicted = list(),
list()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>for i, source in
enumerate(sources):<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span># translate
encoded source text<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>source =
source.reshape((1, source.shape[0]))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>translation =
predict_sequence(model, eng_tokenizer, source)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>raw_target,
raw_src = raw_dataset[i]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>if i < 10:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 3;"> </span>print('src=[%s],
target=[%s], predicted=[%s]' % (raw_src, raw_target, translation))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>actual.append(raw_target.split())<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 2;"> </span>predicted.append(translation.split())<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span># calculate BLEU score<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('BLEU-1: %f' %
corpus_bleu(actual, predicted, weights=(1.0, 0, 0, 0)))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('BLEU-2: %f' %
corpus_bleu(actual, predicted, weights=(0.5, 0.5, 0, 0)))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('BLEU-3: %f' %
corpus_bleu(actual, predicted, weights=(0.3, 0.3, 0.3, 0)))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-tab-count: 1;"> </span>print('BLEU-4: %f' %
corpus_bleu(actual, predicted, weights=(0.25, 0.25, 0.25, 0.25)))<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load
datasets<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
dataset =
load_clean_sentences('english-german-both.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
train =
load_clean_sentences('english-german-train.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test =
load_clean_sentences('english-german-test.pkl')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
english tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
eng_tokenizer
= create_tokenizer(dataset[:, 0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
eng_vocab_size
= len(eng_tokenizer.word_index) + 1<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
eng_length =
max_length(dataset[:, 0])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
german tokenizer<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ger_tokenizer
= create_tokenizer(dataset[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ger_vocab_size
= len(ger_tokenizer.word_index) + 1<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
ger_length =
max_length(dataset[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# prepare
data<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
trainX =
encode_sequences(ger_tokenizer, ger_length, train[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
testX =
encode_sequences(ger_tokenizer, ger_length, test[:, 1])<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# load model<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
model =
load_model('model.h5')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# test on
some training sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print('train')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
evaluate_model(model,
eng_tokenizer, trainX, train)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
# test on
some test sequences<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
print('test')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
evaluate_model(model,
eng_tokenizer, testX, test)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
-----------------------------------------------------------------------------------------
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
OUTPUTS:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
English
Vocabulary Size: 2309<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
English Max
Length: 5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
German
Vocabulary Size: 3657<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
German Max
Length: 10<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Neural
Network Structureeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
_________________________________________________________________<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Layer
(type)<span style="mso-spacerun: yes;"> </span>Output Shape<span style="mso-spacerun: yes;"> </span>Param #<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
=================================================================<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
embedding_2
(Embedding)<span style="mso-spacerun: yes;"> </span>(None, 10, 256)<span style="mso-spacerun: yes;"> </span>936192<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
_________________________________________________________________<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
lstm_3
(LSTM)<span style="mso-spacerun: yes;"> </span>(None, 256)<span style="mso-spacerun: yes;"> </span>525312<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
_________________________________________________________________<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
repeat_vector_2
(RepeatVecto (None, 5, 256)<span style="mso-spacerun: yes;">
</span>0<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
_________________________________________________________________<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
lstm_4
(LSTM)<span style="mso-spacerun: yes;"> </span>(None, 5, 256)<span style="mso-spacerun: yes;"> </span>525312<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
_________________________________________________________________<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
time_distributed_2
(TimeDist (None, 5, 2309)<span style="mso-spacerun: yes;">
</span>593413<span style="mso-spacerun: yes;"> </span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
=================================================================<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Total
params: 2,580,229<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Trainable
params: 2,580,229<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Non-trainable
params: 0<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
_________________________________________________________________<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
None<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Train on
9000 samples, validate on 1000 samplessssssssssssssssssssssssssssssssssssss<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 1/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 76s - loss: 4.2931 - val_loss: 3.5462<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00001:
val_loss improved from inf to 3.54621, saving model to model.h5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 2/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 85s - loss: 3.3974 - val_loss: 3.4251<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00002:
val_loss improved from 3.54621 to 3.42512, saving model to model.h5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 3/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 87s - loss: 3.2527 - val_loss: 3.3515<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00003:
val_loss improved from 3.42512 to 3.35154, saving model to model.h5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 4/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 89s - loss: 3.1077 - val_loss: 3.2153<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
...<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
...<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
...<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 27/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 91s - loss: 0.5958 - val_loss: 1.9781<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00027:
val_loss improved from 1.97907 to 1.97811, saving model to model.h5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 28/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 92s - loss: 0.5441 - val_loss: 1.9675<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00028:
val_loss improved from 1.97811 to 1.96752, saving model to model.h5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 29/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 93s - loss: 0.4995 - val_loss: 1.9564<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00029:
val_loss improved from 1.96752 to 1.95638, saving model to model.h5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 30/30<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>- 92s - loss: 0.4564 - val_loss: 1.9632<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Epoch 00030:
val_loss did not improve from 1.95638<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
PREDICTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
runfile('C:/Users/ars/.spyder-py3/trans4.py',
wdir='C:/Users/ars/.spyder-py3')<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test with
data that has been used in the training phase.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
trainnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
fuhle mich schuldig], target=[i feel guilty], predicted=[i feel guilty]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[tom hat
das bewusstsein verloren], target=[tom passed out], predicted=[tom passed out]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
werde lernen], target=[i will learn], predicted=[i will learn]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[mir
geht es gut], target=[im doing okay], predicted=[im doing well]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich bin
zimmermann], target=[im a carpenter], predicted=[im a carpenter]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[stell
es zuruck], target=[put it back], predicted=[put it back]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[es ist
bewundernswert], target=[its admirable], predicted=[its admirable]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
habe das interesse verloren], target=[i lost interest], predicted=[i lost
interest]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[tom hat
sich gefugt], target=[tom obeyed], predicted=[tom obeyed]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
kann gut kochen], target=[im a good cook], predicted=[i may stay stay]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
C:\Users\ars\Anaconda3\lib\site-packages\nltk\translate\bleu_score.py:503:
UserWarning: <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The
hypothesis contains 0 counts of 2-gram overlaps.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Therefore
the BLEU score evaluates to 0, independently of<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
how many
N-gram overlaps of lower order it contains.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Consider
using lower n-gram order or use SmoothingFunction()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>warnings.warn(_msg)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
C:\Users\ars\Anaconda3\lib\site-packages\nltk\translate\bleu_score.py:503:
UserWarning: <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The
hypothesis contains 0 counts of 3-gram overlaps.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Therefore
the BLEU score evaluates to 0, independently of<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
how many
N-gram overlaps of lower order it contains.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Consider
using lower n-gram order or use SmoothingFunction()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>warnings.warn(_msg)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
C:\Users\ars\Anaconda3\lib\site-packages\nltk\translate\bleu_score.py:503:
UserWarning: <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The
hypothesis contains 0 counts of 4-gram overlaps.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Therefore the
BLEU score evaluates to 0, independently of<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
how many
N-gram overlaps of lower order it contains.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Consider
using lower n-gram order or use SmoothingFunction()<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>warnings.warn(_msg)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-1:
0.077905<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-2:
0.000000<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-3:
0.000000<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-4:
0.000000<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test with
data that has never been introduced to the network before.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
habs im fernsehen gesehen], target=[i saw it on tv], predicted=[i saw it too]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[kommt
zuruck nach hause], target=[come back home], predicted=[come back home]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[entlassen
wir tom], target=[lets fire tom], predicted=[let tom tom]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[er lie
einen drachen steigen], target=[he flew a kite], predicted=[hes seems dead]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
werde mit dem taxi fahren], target=[ill go by taxi], predicted=[ill get by day]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ist es
weit weg], target=[is it far away], predicted=[is it do it]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[ich
bezahlte die rechnung], target=[i paid the bill], predicted=[i saved you]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[tom mag
schnee], target=[tom likes snow], predicted=[tom likes snow]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[es
ist], target=[its], predicted=[its important]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
src=[schlafst
du], target=[are you asleep], predicted=[do you]<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-1:
0.081552<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-2:
0.000000<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-3:
0.000000<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
BLEU-4:
0.000000<o:p></o:p></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-75753713587183797622019-01-22T11:38:00.006-08:002019-01-22T11:38:54.428-08:00Implementing (How to run Keras model on Movidius neural compute stick)<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-outline-level: 1;">
<span style="background-color: transparent;">This is an
implementation report of the article ‘How to run Keras model on Movidius NCS’.</span><span style="background-color: transparent;"> </span><span style="background-color: transparent;">You can read the article at:</span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span><a href="https://www.dlology.com/blog/how-to-run-keras-model-on-movidius-neural-compute-stick/">https://www.dlology.com/blog/how-to-run-keras-model-on-movidius-neural-compute-stick/</a><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<h4 style="background: white; margin-top: 0in;">
<em><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 13.5pt; font-style: normal; font-weight: normal; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: major-bidi;">‘Source code for this post available on my GitHub
repo - </span></em><strong itemprop="name" style="box-sizing: border-box;"><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 13.5pt; font-style: normal; line-height: 115%; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: major-bidi;"><a data-pjax="#js-repo-pjax-container" href="https://github.com/Tony607/keras_mnist" style="box-sizing: border-box;"><span style="color: #337ab7;">keras_mnist</span></a>.’<o:p></o:p></span></strong></h4>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Statement
works OK:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span><a href="https://github.com/Tony607/keras_mnist">https://github.com/Tony607/keras_mnist</a><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The
importance of this example is:<span style="mso-spacerun: yes;"> </span>it trains
a weight file and a json graph file using Keras.<span style="mso-spacerun: yes;"> </span>Then it converts these to a tensor flow
model.<span style="mso-spacerun: yes;"> </span>It loads the graph file to the
Movidius NCS stick.<span style="mso-spacerun: yes;"> </span>At the end it runs
the test example, a number picture(number 6) on the NCS.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Some details
about implementation problems I had:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
A through
README is available.<o:p></o:p></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="color: #24292e; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="color: windowtext;">‘</span><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Optionally, copy this folder into your NCSDK2
directory along with other TensorFlow examples. </span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">ncsdk/examples/tensorflow/keras_mnist</span><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p></o:p></span></li>
<li class="MsoNormal" style="color: #24292e; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Plug NCS to a USB port on the
host machine.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: #24292e; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Run command - </span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">make all</span><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p></o:p></span></li>
<li class="MsoNormal" style="color: #24292e; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in;"><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">Run command - </span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;">make run</span><span style="font-family: "Segoe UI","sans-serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: TR;"><o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
But the
copying is not optional.<span style="mso-spacerun: yes;"> </span>Because:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
MAKEFILE
does:<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="font-family: "System","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: System;">prereqs:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "System","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: System;"><span style="mso-tab-count: 1;"> </span>(cd
../../data/ilsvrc12; make)<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "System","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: System;">Make all produced the KERAS model with a long
output but with the problem:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Training
finished. If you want to retrain the model, delete 'weights.h5' and
'model.json' files.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
(test -f
weights.h5 && test -f model.json) || (echo "Please run \'make
train\' first.")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test -f
TF_Model/tf_model.meta || ./convert-mnist.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from: can't
read /var/mail/keras.models<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
from: can't
read /var/mail/keras<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
./convert-mnist.py:
8: ./convert-mnist.py: model_file: not found<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
./convert-mnist.py:
9: ./convert-mnist.py: weights_file: not found<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
./convert-mnist.py:
11: ./convert-mnist.py: Syntax error: "(" unexpected<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Makefile:45:
recipe for target 'weights' failed<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
make: ***
[weights] Error 2<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The solution
was to install KERAS with:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Pip3 install
keras<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
It did
another error which I corrected with putting at the top of convert-mnist.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
And at the
top of makeFile:<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
#!
/usr/bin/python3.5<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
After this I
got the error:<span style="mso-spacerun: yes;"> </span><span style="background: cornsilk; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 115%;">ImportError: cannot import name '_validate_lengths'</span><o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: cornsilk; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 115%;">Icorrected this by first:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: cornsilk; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 115%;">Pip3 install numpy<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: cornsilk; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 115%;">And then because of its sideeffect I
installed:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: cornsilk; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 115%;">Pip3 scikit-image<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: cornsilk; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 115%;">The result is:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
arsaral@ars:~/ncsdk/ncappzoo-ncsdk2/apps/keras_mnist-master$
make run<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
(test -f
weights.h5 && test -f model.json) || python3 ./train-mnist.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Training
finished. If you want to retrain the model, delete 'weights.h5' and
'model.json' files.<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
(test -f
weights.h5 && test -f model.json) || (echo "Please run \'make
train\' first.")<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test -f
TF_Model/tf_model.meta || ./convert-mnist.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
test -f
graph || mvNCCompile -s 12 TF_Model/tf_model.meta -in=conv2d_1_input
-on=dense_2/Softmax<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
python3
./predict-mnist-ncsdk2.py<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
/usr/local/lib/python3.5/dist-packages/mvnc/mvncapi.py:416:
DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves
surprisingly on unicode inputs. Use frombuffer instead<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>tensor = numpy.fromstring(tensor.raw,
dtype=numpy.float32)<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
NCS <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>[8.3982944e-05 0.0000000e+00 0.0000000e+00
0.0000000e+00 0.0000000e+00<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="mso-spacerun: yes;"> </span>2.1958351e-04 9.9804688e-01 0.0000000e+00
1.2531281e-03 0.0000000e+00] <o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
Predicted: 6<o:p></o:p></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
The inferred
picture is:<o:p></o:p></div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinB6knIk-b3TCKkrT1J9FtBodzAC9NpVm9SBhly5pbkOlkhTQj-nwEMIZ2hbCql0tm9uy-VpoQgS30rpA6NClNRKTCzeO4ZQkgrEYj6GoFGh71lqxbao9zkJPaGOR2ZgglZQ8xKX89BSmZ/s1600/photo_6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="271" data-original-width="269" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinB6knIk-b3TCKkrT1J9FtBodzAC9NpVm9SBhly5pbkOlkhTQj-nwEMIZ2hbCql0tm9uy-VpoQgS30rpA6NClNRKTCzeO4ZQkgrEYj6GoFGh71lqxbao9zkJPaGOR2ZgglZQ8xKX89BSmZ/s1600/photo_6.jpg" /></a></div>
<br />
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.comtag:blogger.com,1999:blog-345401084154429965.post-30511394691599114382019-01-21T10:53:00.002-08:002019-01-21T10:53:17.911-08:00image classifying with Movidius Neural Compute StickImage classifying with Movidius Neural Compute Stick<br />
<br />
<br />
<div class="MsoNormal">
I have installed Movidius NCSDK on my Windows 10 machine and
did some testing.<span style="mso-spacerun: yes;"> </span>In the pictures below
you will kindly see that image-classifier software working on UBUNTU Linux
operating system and on VM Virtual Box<span style="mso-spacerun: yes;">
</span>classifies a cat and a dog correctly.<span style="mso-spacerun: yes;">
</span>In fact it classifies that the dog is a Labrador which I would not be
able to.<span style="mso-spacerun: yes;"> </span>I am not a great fan of dogs.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
There is a neural network behind all this.<span style="mso-spacerun: yes;"> </span>It is GoogLeNet.<span style="mso-spacerun: yes;"> </span>This is a tensorfile which includes all the
elements of a neural network which is trained by Google to classify images.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Movidius NCS Neural Computing Stick is a small USB device to
which the GoogleNet tensor file, namel graph is loaded.<span style="mso-spacerun: yes;"> </span>To make an inference a picture – a cat.jpg
and later a dog.jpg is also loaded to the Movidius NCS.<span style="mso-spacerun: yes;"> </span>After a while, a short while, the results are
given back from the Movidius NCS.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Speed, processing power, less heating are some advantages of
the Movidius NCS.<o:p></o:p></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-9Uexx5bYPwE/XEYUzQm2AqI/AAAAAAAABIU/V6ClKgOoal0Hq8pyr_KjsViLN2-Gd14YwCLcBGAs/s1600/image_classifier0.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="606" data-original-width="803" height="301" src="https://1.bp.blogspot.com/-9Uexx5bYPwE/XEYUzQm2AqI/AAAAAAAABIU/V6ClKgOoal0Hq8pyr_KjsViLN2-Gd14YwCLcBGAs/s400/image_classifier0.jpg" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-SMtUjYX_RCE/XEYUz4D-Z6I/AAAAAAAABIY/5TLzM-nkBZM58HgRTQEQJewcaSFV-KNFQCLcBGAs/s1600/image_classifier1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="606" data-original-width="803" height="241" src="https://2.bp.blogspot.com/-SMtUjYX_RCE/XEYUz4D-Z6I/AAAAAAAABIY/5TLzM-nkBZM58HgRTQEQJewcaSFV-KNFQCLcBGAs/s320/image_classifier1.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-RvKbiZOikh4/XEYU51vTnHI/AAAAAAAABIc/bccnM9iuE8gtr8asz-mhUiugiu5uOD0oQCLcBGAs/s1600/pic_020ARS.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="224" data-original-width="224" src="https://3.bp.blogspot.com/-RvKbiZOikh4/XEYU51vTnHI/AAAAAAAABIc/bccnM9iuE8gtr8asz-mhUiugiu5uOD0oQCLcBGAs/s1600/pic_020ARS.jpg" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgB9BqA7DK6FiYEv6S1Nwm_jahSRMmk-eNRFvUXqBX83B31Y6qZSbJzbwMXXpJxPUNMen4wvsWUnXc2erfQ5LH461RudGqiXIYE0LTytKge2jPETqIt0TQenVVsuZFJriVXuu5rD3zd7Q/s1600/image_classifier3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="712" data-original-width="951" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgB9BqA7DK6FiYEv6S1Nwm_jahSRMmk-eNRFvUXqBX83B31Y6qZSbJzbwMXXpJxPUNMen4wvsWUnXc2erfQ5LH461RudGqiXIYE0LTytKge2jPETqIt0TQenVVsuZFJriVXuu5rD3zd7Q/s400/image_classifier3.jpg" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<br />Air Traffic Control and Large Systemshttp://www.blogger.com/profile/12383935845301881036noreply@blogger.com