<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Ebrahim (Abe) Kazemzadeh</title>
<link>https://abecode.github.io/</link>
<atom:link href="https://abecode.github.io/index.xml" rel="self" type="application/rss+xml"/>
<description>Abe Kazemzadeh&#39;s homepage and blog.</description>
<generator>quarto-1.11.9</generator>
<lastBuildDate>Tue, 06 Dec 2022 00:00:00 GMT</lastBuildDate>
<item>
  <title>2022 Affective Computing and Intelligent Interaction Conference</title>
  <link>https://abecode.github.io/posts/ACII2022-Nara-Japan/</link>
  <description><![CDATA[ 




<p>I attended a very interesting conference a few weeks ago, the 10th <a href="https://acii-conf.net/2022/">Affective Computing and Intelligent Interaction (ACII)</a>. I wanted to share some interesting topics that I learned about. I hope this will disseminate some of the important ideas of the conference and some of the ethical considerations related to technologies presented at the conference. I think the ACII conference did a good job of highlighting these ethical considerations and also it is incumbent on people who work in these areas to share information about the new technologies to the public. I won’t be able to go through the whole four day conference but I’ll try to briefly describe the conference and mention some of the main presentations that stuck out to me. I’ll also describe the study I presented, Emotion Twenty Questions Dialog System for Lexical Emotional Intelligence.</p>
<p>First, the conference gets its name from Affective Computing, a field that’s been around in some form for a while, but whose name was coined Rosalind Picard of the MIT Media Lab (they are hosting <a href="https://acii-conf.net/2023/">next year’s ACII</a>). The basic premise of this field is that computers, devices, and other systems that are aware of human emotions (affect) will enable better human-computer interaction. The conference has been around since 2003 and it’s the 10th conference, so it has been held approximately every other year (last year it became annual after being biennial). In the period since the ACII conference was started, the types and capabilities of computers and devices has changed a lot (e.g.&nbsp;smartphones, social media, deep learning), so the field of affective computing has changed a lot too. The theme of <a href="https://www.acii-conf.net/2021/">last year’s ACII conference</a> was “ethical affective computing” and this year’s theme was “affective computing and mental health”. I think these trends show that the field is addressing some of the negative possibilities of affective computing technologies.</p>
<p>One famous example of a negative use of affective computing technologies was an experiment at Facebook/Meta where researchers experimented with changing the proportion of positive and negative stories in users’ timelines in a study called <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4066473/">Emotional Contagion in Social Networks</a>. Of course, people rightfully felt like they were being manipulated in an experiment without explicit consent.</p>
<p>One of the keynote lectures of ACII this year explored this topic of consent in affective computing. In this keynote, Rafael A. Calvo, of the Dyson Institute (yes, the institute founded by Sir James Dyson of Dyson vacuum fame), used <a href="https://cehsp.d.umn.edu/articles/skinner-and-rogers">the Skinner-Rogers debate in 1962 at the University of Minnesota Duluth (yay, Minnesota!)</a> to illustrate the theme of manipulation in psychology. This “debate of the century” pitted the behavioralist psychologist B.F. Skinner against the humanist psychologist Carl Rogers (there is also another famous “debate of the century” between Skinner and Noam Chomsky). Though Skinner had achieved a lot of success in exploring and leveraging animal and human learning in his work (and he was very persuasive and funny in his arguments), Rogers was prescient in his intuitive skepticism about trying to manipulate people’s behavior and the long-term consequences of a purely behavioralist approach. Prof.&nbsp;Calvo suggested that the audience consider Roger’s perspective and showed the importance of the idea of autonomy in several AI declarations, such as the <a href="https://artificialintelligenceact.eu/">EU AI Act</a>. The <a href="https://www.youtube.com/watch?v=olg4Az_hV4Y">whole Skinner-Rogers debate “A Dialog on Education and Control” can be found on Youtube</a>. It’s 4 hours long, but it was good stuff.</p>
<p>Another keynote was given by Jeffrey Cohn, a psychologist at the University of Pittsburg. Actually he had other papers and presentations as well as the keynote, so I may be combining ideas from each. One term that really stuck out was smile ballistics, i.e.&nbsp;the trajectory of a smile from resting face to smile and back again. One of the areas of affective computing under rapid development right now is facial recognition of users’ expressions and another is simulating emotions in robots and avatars. For the latter, if the smile ballistics are not right, the robot or avatar will look artificial or <a href="https://en.wikipedia.org/wiki/Uncanny_valley">“uncanny”</a>. There are many applications for this technology: facial animation (The Walt Disney Company was one of the conference sponsors) and behavioral analytics (ETS, the Educational Testing Service, was another sponsor. Prof.&nbsp;Cohn had a very novel application of facial emotion recognition: deep brain stimulation surgery for intractable obsessive compulsive disorder (OCD). When a patient’s OCD is so bad, the only thing they want to do is the obsessive behavior, which in the extreme can completely prevent them from living a normal, healthy life. These compulsive behaviors give the patient pleasure in a way, but disrupt normal functioning. Implanting a brain stimulator in the cingulate corpus disrupts this by producing a wave of happiness separate from the OCD behavior. The way that surgeons can measure that the electrode is in the right place is by a very big smile on the patient, called the mirth response, and measuring the maximum trajectory of the smile is a quantitative way to determine that the electrode is in the right place. Going back to the ethics issue, of course this kind of surgery is very invasive, so the ethical issues are more similar to medical ethics than AI ethics, so the facial recognition aspect is less of a concern in this case compared to surveillance applications of facial recognition. This type of surgery was pioneered for Parkinson’s disease.</p>
<p>Besides memorable terms like smile ballistics and mirth response, another interesting term I learned at ACII was eustress, a positive form of stress. When we hear the word “stress” there is a negative connotation (distress). However, we can think of a positive form of stress where this is some form of strain or exertion, but it is enjoyable or beneficial. Dimitra Dritsa and Dr.&nbsp;Nimish Biloria from the Universities of Eindhoven, Sidney, and Johannesburg did a study of stress in the context of architecture and urban design for a smart city application. Subjects would wear a sensor that measured galvanic skin response (skin conductance) so it measured both good and bad stress reflected in sweat or clammy skin. I went back to read the paper and I think “eustress” actually came up from the audience questions, not the paper, but the idea was that the devise would register a similar response if the stress was negative (being lost in a noisy, traffic-y, unfamiliar neighborhood) or when vigorously exploring an exciting, new place. This resonated with me because the conference enabled me to visit Japan for the first time and I think something like “eustress” kept me going despite the long plane ride, jetlag, and different language and culture. The eustress/distress distinction also illustrates a way of modeling emotion as a two dimensional space of pleasure and arousal. In this case eustress and distress are both highly aroused, but differ in terms of the pleasure dimension (positive/pleasure vs negative/displeasure) . Certain emotion recognition methods may be able to identify one dimension better than another. In this case the physiological signal of electro-dermal response is able to recognize the arousal in the stress but not the pleasure dimension. Another study by Han Yu, Thomas Vaessen, Inez Myin-Germeys, and Akane Sano at Rice University and Ku Leuven did a similar study measuring subjects in daily life with electrocardiograms in addition to galvanic skin response and looked at building personalized machine learning models.</p>
<p>Another paper where the eustress/distress distinction came up explicitly a study to measure workplace stress in remote workers by Mehrab Bin Morshed, Javier Hernandez, Daniel McDuff, Jina Suh, Esther Howe, Kael Rowan, Marah Abdin, Gonzalo Ramos, Tracy Tran, and Mary Czerwinski from Microsoft Research, Georgia Tech, and Berkeley. Besides using the term eustress, they also used another well-fitting, evocative term, digital phenotype, which is a profile of a user’s digital activity. The information they used to build this digital phenotype was from surveys (both before, during, and after the study) about sleep, emotions, workload, food, and drink; email, calendar, and other application usage; face position and facial action units; and other physiological data from the user’s webcam (I remember meeting Javier Hernandez, one of the authors, at ACII 2011 when he presented about using webcams to measure heart rate). This paper had a component that surveyed they subjects about how comfortable they were with different data collection modalities and data storage scenarios (local or remote), so I think this is a good example of the affective computing field being ethically aware of the study and its implications. Of course it’s possible to imagine dystopian possibilities where companies police their workers’ emotions, but if used correctly, it may be a way to create an optimal work environment where employees have enough, but too much stimulation and the digital phenotype information would be collected consensually.</p>
<p>This brings up another set of well-fitting terms that illustrates the ethical concerns of such technology, surveillance vs sousveillance. In surveilance, people are monitored by others without their consent and not generally for their benefit (sur-, over, -veillance, to watching), while in sousveillance, people have consent and control over the data that is collected about them for their benefit (sous-, under/subservient like a sous-chef is subservient to the chef, the data collection is subservient to the user).</p>
<p>Another good example of facial recognition that I saw at the conference was the FaceGame demo by Krist Shingjergji, Deniz Iren, Corrie Urlings, and Roland Klemke. It is an experiment that uses a game to collect facial expression data. It is hard to collect facial expression data because emotion expression is ephemeral and often rare. Also, not everyone is an actor that can produce precise expressions on demand. The FaceGame experiment uses facial action codes to generate a face with a precise expression and then asks the user/subject to copy that expression. The system then automatically analyzes the user’s facial action units to give feedback (i.e., raise your left eyebrow and flair your nostrils a bit, so that the user will replicate the expression faithfully. This was one presentation that came with a demo so it was cool to see the software in action, <a href="https://facegame.org/">you can try here</a>.</p>
<p>My presentation was also a demo of a data collection game called Emotion Twenty Questions (EMO20Q) that I made with two students, Ola Sanusi and Summer (Huihui) Nie from the University of St.&nbsp;Thomas Graduate Programs in Software and Data Science. Like the FaceGame, the goal of my team’s demo was to collect emotional data, but in our case we wanted to collect text-based data of users describing emotions in a dialog setting (speaking of dialog, Apple was one of the sponsors of the conference and I had a chance to talk to someone from the Siri group). In EMO20Q two players try to guess the emotion that the other is thinking, like the normal twenty questions game, but with emotion words. If our efforts to put the demo online are still working, you can try it at <a href="https://emo20q.org">emo20q.org</a>. In the past (when I was a grad student working on my dissertation) I made an automated agent that played the question-asking role, but the question-answering role was harder because the when the user is asking questions he/she has the dialog initiative (i.e.&nbsp;it becomes a user initiative dialog setting rather than system initiative setting). However, now 10 years after my grad school days, natural language processing technology (NLP) has advanced so much that the question-answering role is much easier due to large language models (LLMs) like BERT. We used BERT to encode emotion questions into BERT’s typically two-sentence slot imput format: “&lt;CLS&gt; emotion &lt;SEP&gt; question”. For example, if the question-answering agent picked the emotion “stress” and the user asked “is it a positive emotion?”, the BERT input would be “&lt;CLS&gt; stress &lt;SEP&gt; is it a positive emotion?”. The output vector of the &lt;CLS&gt; token is used by the agent’s machine learning model classify the input into “yes”, “no”, or “maybe” by fine-tuning the pre-trained BERT model with older data that I collected when I was a grad student. Actually the first time I attended ACII was when I was a grad student finishing my dissertation, so this was somewhat of a patient (or lazy) way of completing the project by waiting for the technology to solve the problem that had stumped me when I was doing my PhD. You can see <a href="https://arxiv.org/pdf/2210.02400.pdf">our demo paper at Arxiv “Emotion Twenty Questions Dialog System for Lexical motional”</a>. We also published code for the <a href="https://github.com/abecode/emo20q">dialog agent</a> and <a href="https://github.com/abecode/emo20q-web">web frontend</a>.</p>
<p>Finally, to return to the topic of ethics, I also wanted to mention a layer of ethics review that happens at universities before starting a project of this kind of research. Universities that conduct research have an Institutional Review Board (IRB) that vets and documents research projects that have human subjects. This is especially important in medical studies (e.g brain implants for OCD), but many other fields dial with human subjects, including participants of statistical surveys, interviewees in historical research, and users of computer programs. The University of St.&nbsp;Thomas has a very active IRB (thanks Sarah Muenster-Blakley!) that does this vetting and also runs seminars a few times a semester.</p>
<p>This wasn’t a complete overview of the ACII 2022 conference by any means, just a quick taste of some of the things that stood out and I felt like relaying to the general public here on on my blog. For more information, the proceedings can be found at the <a href="https://ieeexplore.ieee.org/xpl/conhome/9597394/proceeding">IEEE Explore website</a>, although the demo system and doctoral consortium papers are not posted yet.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>dialog</category>
  <category>conferences</category>
  <category>emo20q</category>
  <category>ACII</category>
  <category>emotion</category>
  <guid>https://abecode.github.io/posts/ACII2022-Nara-Japan/</guid>
  <pubDate>Tue, 06 Dec 2022 00:00:00 GMT</pubDate>
</item>
<item>
  <title>BERT-Assisted Semantic Annotation Correction for Emotion-Related Questions</title>
  <link>https://abecode.github.io/posts/arduous-bert-assisted-annotation/</link>
  <description><![CDATA[ 




<p>I recently got a paper <a href="../../assets/2022007804.pdf"><strong>BERT-Assisted Semantic Annotation Correction for Emotion-Related Questions</strong></a> accepted at the <a href="https://text2hbm.org/arduous/">ARDUOUS 2022 workshop (Annotation of useR Data for UbiquitOUs Systems)</a> of the <a href="https://www.percom.org/">IEEE Pervasive Computing (PerCom) conference</a>. It was going to be in Pisa, Italy, but unfortunately due to Covid it is now virtual/online.</p>
<p>I wanted to make a short post to describe the paper and share some resources that can be used to replicate it.</p>
<section id="summary" class="level3">
<h3 class="anchored" data-anchor-id="summary">Summary</h3>
<p>First, to summarize, the paper is about using machine learning (ML) models, BERT in particular, to assist annotation by correcting incorrect annotations. There’s been a lot of work in automating the annotation task and this is one take on it (other directions in this area are <em>preannotation</em>, using ML to roughly annotate the data first and having humans fix problems, and <em>online</em>, <em>incremental</em>, and <em>active learing</em> to complete either learn while the humans annotate and/or choosing informative examples for humans to annotate).</p>
</section>
<section id="motivation" class="level3">
<h3 class="anchored" data-anchor-id="motivation">Motivation</h3>
<p>I was inspired to look at this because I realized that the BERT models performed so well that they identified errors in my earlier annotations. When I was a grad student I did annotation by myself and didn’t have the opportunity to check inter-annotator agreement. I had already used funding to collect data on mturk and the performance of my system was good so I skipped the inter-annotator agreement, but it was always something I thought I should do at some point. This current paper didn’t give inter-annotator agreement but it solved the issue of finding annotation errors, which is one of the reasons to find inter-annotator agreement.</p>
</section>
<section id="data-and-previous-work" class="level3">
<h3 class="anchored" data-anchor-id="data-and-previous-work">Data and Previous Work</h3>
<p>The data came from EMO20Q, a dialog system to play an emotion-guessing game (20 questions, but limited to emotions). More info about the EMO20Q project and data can be found at the <a href="https://github.com/abecode/emo20q">github repo</a>. The most relevant previous paper is <a href="https://scholar.google.com/scholar?oi=bibs&amp;hl=en&amp;cluster=7144330598938288097">here</a> and <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:Wp0gIr-vW9MC">here</a> <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:4DMP91E08xMC">are</a> <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:M3ejUd6NZC8C">some</a> <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:0EnyYjriUFMC">other</a> <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:LkGwnXOMwfcC">older</a> <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:hqOjcs7Dif8C">publications</a> as well as a <a href="https://scholar.google.com/citations?view_op=view_citation&amp;hl=en&amp;user=9Bma3uAAAAAJ&amp;sortby=pubdate&amp;citation_for_view=9Bma3uAAAAAJ:YlPif8NxrbYC">newer poster by a student, Shanshan Kong</a>.</p>
</section>
<section id="code" class="level3">
<h3 class="anchored" data-anchor-id="code">Code</h3>
<p>Thanks to the ease of sharing via github and the convenient GPU notebook platform Colab, it’s possible to easily reproduce the work. If you are interested, please see <a href="https://colab.research.google.com/drive/1sXqTT2DoJ1hFBR02iM8W4GKZe5OxCYJy?usp=sharing"><strong>this notebook for details</strong></a>.</p>


</section>

<p>clustrmaps.html</p> ]]></description>
  <category>BERT</category>
  <category>NLP</category>
  <category>writing</category>
  <category>conferences</category>
  <category>emo20q</category>
  <category>annotation</category>
  <category>paraphrase</category>
  <guid>https://abecode.github.io/posts/arduous-bert-assisted-annotation/</guid>
  <pubDate>Mon, 17 Jan 2022 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Using Django to Teach Databases</title>
  <link>https://abecode.github.io/posts/example-django-models-for-SEIS-630/</link>
  <description><![CDATA[ 




<p>I’ve been trying using Django’s ORM to teach some database topics: object-relational-mapping, foreign keys, automatically generated intersection tables vs association tables (Django model “through” attribute), forward and reverse engineering, and migrations. <a href="https://github.com/abecode/630_django_example">Here’s a basic django model that I’ve been using in the class (SEIS 630)</a>. You can check out the code but it’s better to go through the steps using <code>django-admin</code> and <code>manage.py</code>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>django</category>
  <category>stthomas</category>
  <category>databases</category>
  <category>630</category>
  <guid>https://abecode.github.io/posts/example-django-models-for-SEIS-630/</guid>
  <pubDate>Fri, 05 Nov 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Logging Twitter for Years with Tweepy, POSIX/UNIX Signals, Logrotate, Systemd, and S3</title>
  <link>https://abecode.github.io/posts/twitter-listener/</link>
  <description><![CDATA[ 




<p>I’ve been running a Twitter listener for about 2 years and it’s done a pretty good job of staying up and running during that time. In this post I want to explain a bit about how it works. Using utilities outside of Python like <code>logrotate</code>, <code>systemd</code> and <code>aws s3</code> make the Python code look very simple but the interaction of all these is a bit complex. Also, even though the python script is pretty short, there are a few tricks.</p>
<p>First, let’s look at the python script. the code is in the <a href="https://github.com/abecode/twitter-logger/blob/main/listen-and-log.py">listen-and-log.py file</a>. The first 19 lines are imports and environment variables:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/listen-and-log.py?slice=0:20"></script>
<p>Tweepy is the library that actually connects to Twitter, the json library parses the json respons, the os library is used for retrieving environment variables, the signal library is how logrotate signals the script when it’s time to rotate the logfile, sys is used for printing to stderr, and urllib3 is used to catch a type of error (it looks like I commented that exception out.</p>
<p>Then I get environment variables. Environment variables are a good way to pass contextual configuration information to the script. Search 12-factor app, principle 3 for more information. The first environment variable <code>TWITTER_USER</code> is the user whose friendswe will follow. In this case, I’m getting data from an account that I set up with username <code>abestockmon</code> (i.e., it’s a dummy account to monitor stock news (“fintwit”). The following environment variables are tokens provided by Twitter. To get this information from Twitter, you need to get a developer account and create a project. Since I set this up two years ago I don’t remember exactly what each of these do but you can see their usage later in the script.</p>
<p>Finally, the last line opens the log file. This is where the json from Twitter will be saved. It’s slightly different from the normal file opening in python. First, it’s opening a gzip file, so everything that’s written will be saved as gzip. Second, it doesn’t use the normal</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">with</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">open</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">file</span>) <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> f:</span>
<span id="cb1-2">  ...</span></code></pre></div></div>
<p>idiom. This is because we want the file handle to be available to the next function:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/listen-and-log.py?slice=21:30"></script>
<p>This function is called when the HUP (hangup) signal is received. Signals are kind of cool because unlike ordinary Python function calls they can get called from outside the Python script and they are called in the middle of the script execution, interrupting the script. So the script is running, writting json from Twitter and it receives the HUP signal. Wherever the script is, it will run this function. It takes the filehandle <code>f</code>, saves it to the <code>f_old</code> variable, then opens a new file, and closes the old file. Anything that was being written will go to the old file, but anything that runs after this function is going to the new file. It looks like these would be the same file, but actually logrotate has changed the file name outside of the python script (the old file is renamed to <code>twitter.log.gz.1</code>).</p>
<p>The next chunk defines a stream listener class that simply writes the received json from Twitter to the logfile:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/listen-and-log.py?slice=32:39"></script>
<p>The following function takes the stream and a list of twitter users and filters the stream bast on this followlist:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/listen-and-log.py?slice=39:50"></script>
<p>The main function below sets up the signal handler, the Twitter credentials, gets the users that the <code>abestockmon</code> user follows, creates the stream, and then runs <code>filter</code> on the stream:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/listen-and-log.py?slice=50:68"></script>
<p>If this running script did not receive any signal from outside, it would keep writing to its logfile, which would grow and grow. We can manually send a HUP signal like this:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">kill</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-HUP</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pgrep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-f</span> listen-and-log.py<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<p>This is what I did when I was testing the script, but logrotate does it automatically and the logrotation is specified declaratively in the logrotate.conf file:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/logrotate.conf"></script>
<p>This config file tells the logrotate UNIX/Linux command where the logfile is, minimally how often to rotate it, what the maximum size should be before it is rotated, and how many old log files are saved. The <code>postrotate</code> block specifies what happens after the log is rotated, i.e., renaming the twitter.log.gz file to twitter.log.gz.1. The main thing is that <code>logrotate</code> sends the Python script to send the HUP signal and then it copies the old log file to aws S3. This prevents logfiles from accumulating on the server and offloads them to AWS S3.</p>
<p>Finally, every now and then there can be transient issues that will cause the script to fail and die. It could happen in the middle of the night and I wouldn’t know about it so I wanted to make sure that it restarted automatically. To do this, I created a Systemd service unit file:</p>
<script src="https://gist-it.appspot.com/http://github.com/abecode/twitter-logger/raw/main/listen-and-log.service"></script>
<p>A service unit file will make the script run as a daemon in the background. It reads an enviroment variable file and it will restart the process after two seconds if it fails. Waiting two seconds is good because if you try to restart too quickly you could overload the system. The final line makes the script start automatically when the AWS Linux VM starts.</p>
<p>This looks simple but it took some work to get it working right. I learned this pattern from my old boss Kim Scheibel, then at Adly, now at Google (thanks Kim!). Back then we used Upstart instead of Systemd (Systemd is still relatively new although now it is the default).</p>
<p>This approach does lose data when the script restarts. In a more critical system, we would have multiple listeners running in different availability zones so that if a problem happened to one, then there would be another that would most likely still be running. This would require a deduplication phase and so it gets a lot more complex than what I’ve shown here.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>twitter</category>
  <category>devops</category>
  <category>linux</category>
  <category>aws</category>
  <guid>https://abecode.github.io/posts/twitter-listener/</guid>
  <pubDate>Fri, 23 Jul 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>My Online Teaching Setup</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/my-online-teaching-setup/</link>
  <description><![CDATA[ 




<p>I’ve actually been enjoying teaching online during Covid-19. Besides the ability to have a soundtrack/theme (Between Two Ferns) and sound effects (applause and various boing noises from a midi keyboard), I’ve enjoyed using <a href="https://obsproject.com/">OBS Studio</a> a lot. Below is a schematic diagram of the setup I use for teaching using OBS and Zoom Pro:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://abecode.github.io/assets/obs-teaching-setup.png" class="img-fluid figure-img"></p>
<figcaption>Abe’s setup for OBS and Zoom</figcaption>
</figure>
</div>
<p>Here’s the splash screen with arcade classic font that’s made to look like <a href="https://en.wikipedia.org/wiki/Between_Two_Ferns_with_Zach_Galifianakis#/media/File:Between_Two_Ferns_with_Zach_Galifianakis.png">Between Two Ferns</a> (typo partially intentional) : <img src="https://abecode.github.io/assets/arcade-logo-bak.png" class="img-fluid" alt="Between Two Ferns"></p>



<p>clustrmaps.html</p> ]]></description>
  <category>teaching</category>
  <guid>https://abecode.github.io/posts/my-online-teaching-setup/</guid>
  <pubDate>Thu, 18 Feb 2021 00:00:00 GMT</pubDate>
</item>
<item>
  <title>First Steps with BERT</title>
  <link>https://abecode.github.io/posts/first-tries-with-bert/</link>
  <description><![CDATA[ 




<p>I’m trying both BERT for the first time and I wanted to document it using Jekyll/Github Pages, which I’m also new to.</p>
<p>The <a href="https://github.com/google-research/bert">README.md file on the BERT github page</a> is pretty long and there are many variations on the BERT model provided there.</p>
<p>Since data a model is not trainable or testable without data, I started by <a href="https://github.com/google-research/bert#sentence-and-sentence-pair-classification-tasks">downloading the glue data</a>. I had to make some changes to the <a href="https://gist.github.com/W4ngatang/60c2bdb54d156a41194446737ce03e2e">download script gist</a> that was linked in this section.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">python3</span> download_glue_data.py <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--data_dir</span> glue_data <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--tasks</span> all</span></code></pre></div></div>
<p>Then I downloaded and unzipped a model. There were many models provided and I chose <a href="https://storage.googleapis.com/bert_models/2018_11_23/multi_cased_L-12_H-768_A-12.zip">the one that was “recommended”, multi_cased_L-12_H-768_A-12</a></p>
<p>Then I ran the commands from the README:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">BERT_BASE_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>multi_cased_L-12_H-768_A-12</span>
<span id="cb2-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">GLUE_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>glue_data</span>
<span id="cb2-3"></span>
<span id="cb2-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">python</span> run_classifier.py <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--task_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>MRPC <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_train</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>true <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_eval</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>true <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--data_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$GLUE_DIR</span>/MRPC <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--vocab_file</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/vocab.txt <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--bert_config_file</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/bert_config.json <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--init_checkpoint</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/bert_model.ckpt <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--max_seq_length</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>128 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--train_batch_size</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>32 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--learning_rate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>2e-5 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--num_train_epochs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>3.0 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--output_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>/tmp/mrpc_output/</span></code></pre></div></div>
<p>I realized I needed some libraries and I also ought to be in a virtualenv:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">mkvirtualenv</span> bert</span>
<span id="cb3-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">workon</span> bert</span>
<span id="cb3-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> requirements.txt</span></code></pre></div></div>
<p>Now trying to run the run_classifier.py script, I get the following error:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb4-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 25, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb4-3">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">import</span> optimization</span>
<span id="cb4-4">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/proj/bert/optimization.py"</span>, line 87, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb4-5">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">class</span> AdamWeightDecayOptimizer<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tf.train.Optimizer</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb4-6"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow._api.v2.train'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Optimizer'</span></span></code></pre></div></div>
<p>Googling led to <a href="https://github.com/tensorflow/tensorflow/issues/30092">this</a></p>
<p>so I tried import tf.keras.optimizers and changing the line 87 in bert/optimization.py to</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> AdamWeightDecayOptimizer(tf.keras.optimizers.Optimizer):</span></code></pre></div></div>
<p>That seemed to solve that problem but I got another error:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb6-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 29, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb6-3">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">flags</span> = tf.flags</span>
<span id="cb6-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'flags'</span></span></code></pre></div></div>
<p>according to <a href="https://github.com/tensorflow/tensor2tensor/issues/1754">this</a> it seems like it’s a version issue that can be fixed by changing line 29 to</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1">flags <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> tf.compat.v1.flags</span></code></pre></div></div>
<p>but still another error:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb8-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb8-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 102, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb8-3">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tf.flags.DEFINE_string</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span></span>
<span id="cb8-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'flags'</span></span></code></pre></div></div>
<p>To fix this there were a few lines that I changed <code>tf.flags</code> to just <code>flags</code></p>
<p>After fixing that, another error:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb9-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb9-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 981, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb9-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tf.app.run()</span></span>
<span id="cb9-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'app'</span></span></code></pre></div></div>
<p>to fix, based on reading <a href="https://stackoverflow.com/questions/58258003/attributeerror-module-tensorflow-has-no-attribute-app">this</a> change line 24 to:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> tensorflow.compat.v1 <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> tf</span></code></pre></div></div>
<p>New error:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb11-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb11-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 981, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb11-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tf.app.run()</span></span>
<span id="cb11-4">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/tensorflow/python/platform/app.py"</span>, line 40, in run</span>
<span id="cb11-5">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">main</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>main, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>argv, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">flags_parser</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>_parse_flags_tolerate_undef<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb11-6">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 303, in run</span>
<span id="cb11-7">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run_main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main,</span> args<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb11-8">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 251, in _run_main</span>
<span id="cb11-9">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">sys.exit</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">argv</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">))</span></span>
<span id="cb11-10">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 793, in main</span>
<span id="cb11-11">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tokenization.validate_case_matches_checkpoint</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">FLAGS.do_lower_case,</span></span>
<span id="cb11-12">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/proj/bert/tokenization.py"</span>, line 69, in validate_case_matches_checkpoint</span>
<span id="cb11-13">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">raise</span> ValueError<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span></span></code></pre></div></div>
<p>it seems that the command I was using should be modified to</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb12-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">python</span> run_classifier.py <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--task_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>MRPC <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_train</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>true <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_eval</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>true <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--data_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$GLUE_DIR</span>/MRPC <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--vocab_file</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/vocab.txt <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--bert_config_file</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/bert_config.json <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--init_checkpoint</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/bert_model.ckpt <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--max_seq_length</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>128 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--train_batch_size</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>32 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--learning_rate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>2e-5 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--num_train_epochs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>3.0 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--output_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>/tmp/mrpc_output/ <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb12-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_lower_case</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>false  /</span></code></pre></div></div>
<p>now I’m getting an error about gfile</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb13-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb13-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 981, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb13-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tf.app.run()</span></span>
<span id="cb13-4">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/tensorflow/python/platform/app.py"</span>, line 40, in run</span>
<span id="cb13-5">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">main</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>main, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>argv, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">flags_parser</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>_parse_flags_tolerate_undef<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb13-6">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 303, in run</span>
<span id="cb13-7">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run_main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main,</span> args<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb13-8">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 251, in _run_main</span>
<span id="cb13-9">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">sys.exit</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">argv</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">))</span></span>
<span id="cb13-10">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 800, in main</span>
<span id="cb13-11">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">bert_config</span> = modeling.BertConfig.from_json_file<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">FLAGS.bert_config_file</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb13-12">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/proj/bert/modeling.py"</span>, line 93, in from_json_file</span>
<span id="cb13-13">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">with</span> tf.gfile.GFile<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">json_file,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as</span> reader:</span>
<span id="cb13-14"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'gfile'</span></span></code></pre></div></div>
<p>according to <a href="https://github.com/google-research/bert/issues/977">this</a> we need to patch like this</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1">tf.gfile <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> tf.io.gfile</span></code></pre></div></div>
<p>in the files that use gfile (run_classifier.py and modeling.py)</p>
<p>new error</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb15-1">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 982, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb15-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tf.app.run()</span></span>
<span id="cb15-3">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/tensorflow/python/platform/app.py"</span>, line 40, in run</span>
<span id="cb15-4">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">main</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>main, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>argv, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">flags_parser</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>_parse_flags_tolerate_undef<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb15-5">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 303, in run</span>
<span id="cb15-6">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run_main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main,</span> args<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb15-7">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 251, in _run_main</span>
<span id="cb15-8">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">sys.exit</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">argv</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">))</span></span>
<span id="cb15-9">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 809, in main</span>
<span id="cb15-10">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tf.gfile.MakeDirs</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">FLAGS.output_dir</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb15-11"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow.compat.v1.io.gfile'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'MakeDirs'</span></span></code></pre></div></div>
<p>try changeing that line to “makedirs” (lowercase) according to <a href="https://www.tensorflow.org/api_docs/python/tf/io/gfile/makedirs">this</a></p>
<p>new error</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb16-1"></span>
<span id="cb16-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Traceback</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">most</span> recent call last<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb16-3">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 982, in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>module<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span></span>
<span id="cb16-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tf.app.run()</span></span>
<span id="cb16-5">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/tensorflow/python/platform/app.py"</span>, line 40, in run</span>
<span id="cb16-6">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">main</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>main, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>argv, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">flags_parser</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>_parse_flags_tolerate_undef<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb16-7">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 303, in run</span>
<span id="cb16-8">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">_run_main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main,</span> args<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb16-9">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/Users/kaze7539/.virtualenvs/bert/lib/python3.8/site-packages/absl/app.py"</span>, line 251, in _run_main</span>
<span id="cb16-10">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">sys.exit</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">argv</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">))</span></span>
<span id="cb16-11">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">File</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run_classifier.py"</span>, line 828, in main</span>
<span id="cb16-12">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">is_per_host</span> = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2</span>
<span id="cb16-13"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AttributeError:</span> module <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tensorflow.compat.v1'</span> has no attribute <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'contrib'</span></span></code></pre></div></div>
<p>Okay, this is kind of ridiculous. I figured that instead of trying to use the compatibility layers, I actually just need to use the older version of tensor flow which also requires an older version of python</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb17-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">rmvirtualenv</span> bert</span>
<span id="cb17-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># update requirements to</span></span>
<span id="cb17-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># tensorflow == 1.14   # CPU Version of TensorFlow.</span></span>
<span id="cb17-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">mkvirtualenv</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-p</span> /usr/local/bin/python3.7  bert</span>
<span id="cb17-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">workon</span> bert</span>
<span id="cb17-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># update requirements to</span></span>
<span id="cb17-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># tensorflow == 1.14   # CPU Version of TensorFlow.</span></span>
<span id="cb17-8"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> requirements.text</span></code></pre></div></div>
<p>this seems to be working now but there was a subset of the glue data that we need to download separately for legal reasons. My patience was running thin so I tried a different task, CoLA (corpus of linguistic acceptability):</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb18-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">python</span> run_classifier.py <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--task_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>COLA <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_train</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>true <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_eval</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>true <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--data_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$GLUE_DIR</span>/CoLA <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--vocab_file</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/vocab.txt <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--bert_config_file</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/bert_config.json <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--init_checkpoint</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BERT_BASE_DIR</span>/bert_model.ckpt <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--max_seq_length</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>128 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--train_batch_size</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>32 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--learning_rate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>2e-5 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--num_train_epochs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>3.0 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--output_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>/tmp/mrpc_output/ <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb18-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--do_lower_case</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>false  /</span></code></pre></div></div>
<p>The fan turned on so it seems to be running. To be continued…</p>



<p>clustrmaps.html</p> ]]></description>
  <category>nlp</category>
  <guid>https://abecode.github.io/posts/first-tries-with-bert/</guid>
  <pubDate>Thu, 10 Dec 2020 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Welcome to Jekyll and Github Pages!</title>
  <link>https://abecode.github.io/posts/welcome-to-jekyll/</link>
  <description><![CDATA[ 




<p>This was my first time using Jekyll after using Github Pages (gh-pages) a couple of times for several projects, e.g.&nbsp;generating <a href="https://abecode.github.io/emo20q-cn/">some pages to display Chinese emo20q data</a>, which were generated programatically from the data into the default gh-pages and <a href="https://abecode.github.io/631-rtopics/">a site I use for teaching SEIS 631</a>, the stats and R data analysis at UST GPS, which was created using RStudio and RMarkdown.</p>
<p>I’ll also test out code snippets:</p>
<p>I don’t use Ruby too much but it’s the language of Jekyll:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode ruby code-with-copy"><code class="sourceCode ruby"><span id="cb1-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> print_hi(name)</span>
<span id="cb1-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">puts</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hi, </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#{</span>name<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb1-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">end</span></span>
<span id="cb1-4">print_hi(<span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">'Tom'</span>)</span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#=&gt; prints 'Hi, Tom' to STDOUT.</span></span></code></pre></div></div>
<p>Python, my main language:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> print_hi(name):</span>
<span id="cb2-2">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"hi </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>name<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb2-3"></span>
<span id="cb2-4">print_hi(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Tom'</span>)</span>
<span id="cb2-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#=&gt; print 'hi Tom' to STDOUT.</span></span></code></pre></div></div>
<p>R, my recent go-to language and what I’ve been teaching:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">print_hi <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(name){</span>
<span id="cb3-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hi"</span>, name)</span>
<span id="cb3-3">}</span>
<span id="cb3-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print_hi</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Tom'</span>)</span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#=&gt; print 'hi Tom' to STDOUT.</span></span></code></pre></div></div>
<p>Check out the <a href="https://jekyllrb.com/docs/home">Jekyll docs</a> for more info on how to get the most out of Jekyll. File all bugs/feature requests at <a href="https://github.com/jekyll/jekyll">Jekyll’s GitHub repo</a>. If you have questions, you can ask them on <a href="https://talk.jekyllrb.com/">Jekyll Talk</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>jekyll</category>
  <category>update</category>
  <guid>https://abecode.github.io/posts/welcome-to-jekyll/</guid>
  <pubDate>Sat, 05 Dec 2020 00:00:00 GMT</pubDate>
</item>
<item>
  <title>BERT Structural Probes</title>
  <link>https://abecode.github.io/posts/bert-structural-probes/</link>
  <description><![CDATA[ 




<p>c.f. <a href="https://github.com/john-hewitt/structural-probes">John Hewitt’s Structural Probes Github repo</a></p>
<p>use virrtualenv instead of conda</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">mkvirtualenv</span> structuralprobe <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-p</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span> python3.7<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<p>use pip instead of conda</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> requirements.txt</span></code></pre></div></div>
<p>install pytorch</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install torch torchvision torchaudio</span>
<span id="cb3-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install pytorch-pretrained-bert</span></code></pre></div></div>



<p>clustrmaps.html</p> ]]></description>
  <category>jekyll</category>
  <category>update</category>
  <guid>https://abecode.github.io/posts/bert-structural-probes/</guid>
  <pubDate>Sat, 05 Dec 2020 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Deep Dreaming at Vixlet</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/deep-dreaming-at-vixlet/</link>
  <description><![CDATA[ 




<p>Last weekend I started playing around with <a href="http://googleresearch.blogspot.ch/2015/06/inceptionism-going-deeper-into-neural.html">Deep Dreams, an artistic, surreal application of Google’s deep belief neural networks</a> and applied it to a picture from my colleague Steve Eldridge of Vixlet HQ’s inspiring view of downtown LA:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e</figcaption>
</figure>
</div>
<p>Here’s what it looks like at the deepest layer of the deep dream neural network (I’ll explain what that means shortly).</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_5a.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_5a.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_5a</figcaption>
</figure>
</div>
<p>Although there is <a href="https://github.com/google/deepdream/blob/master/dream.ipynb">a tutorial already</a>, I thought I’d make a blog post about it because I had to make some modifications to the code there and people were asking about how I got it working.</p>
<p>First of all, the part that I had to modify was the image loading commands. &nbsp;The tutorial used ipython notebooks, which I’m not very famliar with. Also they loaded the image into a numpy array via PIL, python image library. &nbsp;I’m not sure if it was due to PIL or ipython notebooks, but this didn’t work for me. Instead, I loaded the image to a numpy array via opencv (called cv2 in python). &nbsp;That’s&nbsp;an obvious thing to try if you’re familiar with computer vision in python, but otherwise it would be a place to get stuck. &nbsp;So basically, I used the code from the tutorial but added it to a single script and changed a couple of lines:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#!/usr/bin/env python</span></span>
<span id="cb1-2"></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># imports and basic notebook setup</span></span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> cStringIO <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> StringIO</span>
<span id="cb1-5"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb1-6"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> scipy.ndimage <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> nd</span>
<span id="cb1-7"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> PIL.Image</span>
<span id="cb1-8"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> sys</span>
<span id="cb1-9"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> IPython.display <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> clear_output, Image, display</span>
<span id="cb1-10"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> google.protobuf <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> text_format</span>
<span id="cb1-11"></span>
<span id="cb1-12"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> caffe</span>
<span id="cb1-13"></span>
<span id="cb1-14"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> showarray(a, fmt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'jpeg'</span>):</span>
<span id="cb1-15">    a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.uint8(np.clip(a, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">255</span>))</span>
<span id="cb1-16">    f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> StringIO()</span>
<span id="cb1-17">    PIL.Image.fromarray(a).save(f, fmt)</span>
<span id="cb1-18">    display(Image(data<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>f.getvalue()))</span>
<span id="cb1-19"></span>
<span id="cb1-20">model_path <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'../caffe/models/bvlc_googlenet/'</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># substitute your path here</span></span>
<span id="cb1-21">net_fn   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model_path <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'deploy.prototxt'</span></span>
<span id="cb1-22">param_fn <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> model_path <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'bvlc_googlenet.caffemodel'</span></span>
<span id="cb1-23"></span>
<span id="cb1-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Patching model to be able to compute gradients.</span></span>
<span id="cb1-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Note that you can also manually add "force_backward: true" line to "deploy.prototxt".</span></span>
<span id="cb1-26">model <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> caffe.io.caffe_pb2.NetParameter()</span>
<span id="cb1-27">text_format.Merge(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">open</span>(net_fn).read(), model)</span>
<span id="cb1-28">model.force_backward <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb1-29"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">open</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tmp.prototxt'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'w'</span>).write(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>(model))</span>
<span id="cb1-30"></span>
<span id="cb1-31">net <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> caffe.Classifier(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'tmp.prototxt'</span>, param_fn,</span>
<span id="cb1-32">                       mean <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.float32([<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">104.0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">116.0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">122.0</span>]), <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ImageNet mean, training set dependent</span></span>
<span id="cb1-33">                       channel_swap <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># the reference model has channels in BGR order instead oF\</span></span>
<span id="cb1-34"> RGB</span>
<span id="cb1-35"></span>
<span id="cb1-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a couple of utility functions for converting to and from Caffe's input image layout</span></span>
<span id="cb1-37"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> preprocess(net, img):</span>
<span id="cb1-38">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> np.float32(np.rollaxis(img, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)[::<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> net.transformer.mean[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'data'</span>]</span>
<span id="cb1-39"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> deprocess(net, img):</span>
<span id="cb1-40">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> np.dstack((img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> net.transformer.mean[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'data'</span>])[::<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb1-41"> </span>
<span id="cb1-42"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> make_step(net, step_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, end<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'inception_4c/output'</span>, jitter<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span>, clip<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>):</span>
<span id="cb1-43">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">'''Basic gradient ascent step.'''</span></span>
<span id="cb1-44"></span>
<span id="cb1-45">    src <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> net.blobs[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'data'</span>] <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># input image is stored in Net's 'data' blob</span></span>
<span id="cb1-46">    dst <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> net.blobs[end]</span>
<span id="cb1-47"></span>
<span id="cb1-48">    ox, oy <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.random.randint(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>jitter, jitter<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb1-49">    src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.roll(np.roll(src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], ox, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), oy, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># apply jitter shift</span></span>
<span id="cb1-50"></span>
<span id="cb1-51">    net.forward(end<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>end)</span>
<span id="cb1-52">    dst.diff[:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dst.data  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># specify the optimization objective</span></span>
<span id="cb1-53">    net.backward(start<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>end)</span>
<span id="cb1-54">    g <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> src.diff[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]</span>
<span id="cb1-55">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># apply normalized ascent step to the input image</span></span>
<span id="cb1-56">    src.data[:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span> step_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>np.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">abs</span>(g).mean() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> g</span>
<span id="cb1-57"></span>
<span id="cb1-58">    src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.roll(np.roll(src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>ox, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>oy, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># unshift image</span></span>
<span id="cb1-59"></span>
<span id="cb1-60">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> clip:</span>
<span id="cb1-61">        bias <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> net.transformer.mean[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'data'</span>]</span>
<span id="cb1-62">        src.data[:] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.clip(src.data, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>bias, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">255</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>bias)</span>
<span id="cb1-63"></span>
<span id="cb1-64"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> deepdream(net, base_img, iter_n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, octave_n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, octave_scale<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.4</span>, end<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'inception_4c/output'</span>, clip<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>step_params):</span>
<span id="cb1-65">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># prepare base images for all octaves</span></span>
<span id="cb1-66">    octaves <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [preprocess(net, base_img)]</span>
<span id="cb1-67">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">xrange</span>(octave_n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>):</span>
<span id="cb1-68">        octaves.append(nd.zoom(octaves[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>octave_scale,<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>octave_scale), order<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb1-69"></span>
<span id="cb1-70">    src <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> net.blobs[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'data'</span>]</span>
<span id="cb1-71">    detail <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.zeros_like(octaves[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># allocate image for network-produced details</span></span>
<span id="cb1-72">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> octave, octave_base <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">enumerate</span>(octaves[::<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]):</span>
<span id="cb1-73">        h, w <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> octave_base.shape[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>:]</span>
<span id="cb1-74">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> octave <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>:</span>
<span id="cb1-75">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># upscale details from the previous octave</span></span>
<span id="cb1-76">            h1, w1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> detail.shape[<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>:]</span>
<span id="cb1-77">            detail <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> nd.zoom(detail, (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>h1,<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>w<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>w1), order<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-78"></span>
<span id="cb1-79">        src.reshape(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,h,w) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># resize the network's input image size</span></span>
<span id="cb1-80">        src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> octave_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>detail</span>
<span id="cb1-81">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">xrange</span>(iter_n):</span>
<span id="cb1-82">            make_step(net, end<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>end, clip<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>clip, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>step_params)</span>
<span id="cb1-83"></span>
<span id="cb1-84">            <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># visualization</span></span>
<span id="cb1-85">            vis <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> deprocess(net, src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb1-86">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> clip: <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># adjust image contrast if clipping is disabled</span></span>
<span id="cb1-87">                vis <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> vis<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">255.0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>np.percentile(vis, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">99.98</span>))</span>
<span id="cb1-88">            showarray(vis)</span>
<span id="cb1-89">            <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span> octave, i, end, vis.shape</span>
<span id="cb1-90">            clear_output(wait<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span>)</span>
<span id="cb1-91"></span>
<span id="cb1-92">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># extract details produced on the current octave</span></span>
<span id="cb1-93">        detail <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>octave_base</span>
<span id="cb1-94">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># returning the resulting image</span></span>
<span id="cb1-95">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> deprocess(net, src.data[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb1-96"></span>
<span id="cb1-97"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># this is my humble addition/modification</span></span>
<span id="cb1-98"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> cv2</span>
<span id="cb1-99"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">not</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(sys.argv) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>: <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># check arguments to script</span></span>
<span id="cb1-100">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Usage: ./deepdream.py input_file output_file [level]"</span></span>
<span id="cb1-101">    sys.exit()</span>
<span id="cb1-102">layer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"inception_4c/output"</span></span>
<span id="cb1-103"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>(sys.argv) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>:    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># set default end/layer</span></span>
<span id="cb1-104">    layer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sys.argv[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]</span>
<span id="cb1-105">img <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cv2.imread(sys.argv[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb1-106">dd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> deepdream(net, img, end<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>layer)</span>
<span id="cb1-107">cv2.imwrite(sys.argv[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], dd)</span></code></pre></div></div>
<p><a href="https://gist.github.com/abecode/e7f0c9ab4e284d3fc9b7">Original code on GitHub Gist</a></p>
<p>The core python library that performs the neural network operations is Caffe. If the code above doesn’t work, it could be because I used a version of Caffe that I compiled to make use of the NVidia Cuda libraries. &nbsp;I don’t think that is necessary, but I had been using that to speed up unrelated computer vision work I’ve been doing.</p>
<p>Now I’ll explain a little bit about the inception neural network that deep dreams is based on. &nbsp;The neural network is visualized below.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/googlenet.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/googlenet.jpg" class="img-fluid figure-img"></a></p>
<figcaption>googlenet</figcaption>
</figure>
</div>
<p>You may want to open the pdf (</p>
<p><a href="../../assets/wordpress/2015/07/tmp.pdf">Click to access tmp.pdf</a></p>
<p>) to see it in more detail. &nbsp;The left is the lower level of the neural network that processes the image input and the right is the deeper level of the neural network. &nbsp;The intermediate levels range from the shallow end which identifies edges and shapes, to patterns, and then to patches and objects in the deep end. &nbsp;The “end” named argument to the deepdream function specifies what layer to output, given the input image. &nbsp;Below are a selection of various layers from &nbsp;shallow to deep:</p>
<p>conv1/7x7_s2</p>
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-conv1.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-conv1.jpg" class="img-fluid" alt="steve-e-deep-conv1"></a>&nbsp;</p>
<p>pool1/3x3_s2</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-pool1.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-pool1.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-pool1</figcaption>
</figure>
</div>
<p>pool1/norm1</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-pool1norm1.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-pool1norm1.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-pool1norm1</figcaption>
</figure>
</div>
<p>conv2/3x3_reduce</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-conv2_3x3_reduce.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-conv2_3x3_reduce.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-conv2_3x3_reduce</figcaption>
</figure>
</div>
<p>conv2/3×3</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-conv2_3x3.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-conv2_3x3.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-conv2_3x3</figcaption>
</figure>
</div>
<p>conv2/norm2</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-conv2_norm2.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-conv2_norm2.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-conv2_norm2</figcaption>
</figure>
</div>
<p>pool2/3x3_s2</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-pool2_3x3_s2.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-pool2_3x3_s2.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-pool2_3x3_s2</figcaption>
</figure>
</div>
<p>inception_3a/pool</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_pool.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_pool.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_pool</figcaption>
</figure>
</div>
<p>inception_3a/5x5_reduce</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_5x5_reduce.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_5x5_reduce.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_5x5_reduce</figcaption>
</figure>
</div>
<p>inception_3a/1×1</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_1x1.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_1x1.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_1x1</figcaption>
</figure>
</div>
<p>inception_3a/3x3_reduce</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_3x3_reduce.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_3x3_reduce.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_3x3_reduce</figcaption>
</figure>
</div>
<p>inception_3a/pool_proj</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_pool_proj.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_pool_proj.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_pool_proj</figcaption>
</figure>
</div>
<p>inception_3a/5×5</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_5x5.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_5x5.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_5x5</figcaption>
</figure>
</div>
<p>inception_3a/3×3</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a_3x3.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a_3x3.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a_3x3</figcaption>
</figure>
</div>
<p>inception_3a/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3a.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3a.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3a</figcaption>
</figure>
</div>
<p>inception_3b/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_3b.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_3b.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_3b</figcaption>
</figure>
</div>
<p>inception_4a/pool</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_pool.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_pool.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_pool</figcaption>
</figure>
</div>
<p>inception_4a/5x5_reduce</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_5x5_reduce.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_5x5_reduce.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_5x5_reduce</figcaption>
</figure>
</div>
<p>inception_4a/1×1</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_1x1.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_1x1.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_1x1</figcaption>
</figure>
</div>
<p>inception_4a/3x3_reduce</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_3x3_reduce.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_3x3_reduce.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_3x3_reduce</figcaption>
</figure>
</div>
<p>inception_4a/pool_proj</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_pool_proj.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_pool_proj.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_pool_proj</figcaption>
</figure>
</div>
<p>inception_4a/5×5</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_5x5.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_5x5.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_5x5</figcaption>
</figure>
</div>
<p>inception_4a/3×3</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a_3x3.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a_3x3.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a_3x3</figcaption>
</figure>
</div>
<p>inception_4a/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4a.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4a.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4a</figcaption>
</figure>
</div>
<p>inception_4b/pool</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4b_pool.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4b_pool.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4b_pool</figcaption>
</figure>
</div>
<p>inception_4b/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4b.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4b.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4b</figcaption>
</figure>
</div>
<p>inception_4c/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4c.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4c.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4c</figcaption>
</figure>
</div>
<p>inception_4d/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4d.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4d.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4d</figcaption>
</figure>
</div>
<p>inception_4e/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_4e.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_4e.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_4e</figcaption>
</figure>
</div>
<p>inception_5a/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_5a1.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_5a1.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_5a</figcaption>
</figure>
</div>
<p>inception_5b/output</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/steve-e-deep-inception_5b.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/steve-e-deep-inception_5b.jpg" class="img-fluid figure-img"></a></p>
<figcaption>steve-e-deep-inception_5b</figcaption>
</figure>
</div>
<p>&nbsp;</p>
<p>Here’s one where I ran the deep dream several times:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/07/tmp10.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/07/tmp10.jpg" class="img-fluid figure-img"></a></p>
<figcaption>tmp10</figcaption>
</figure>
</div>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2015/07/09/deep-dreaming-at-vixlet/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/deep-dreaming-at-vixlet/</guid>
  <pubDate>Thu, 09 Jul 2015 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Fun with FFT at Vixlet</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/fun-with-fft-at-vixlet/</link>
  <description><![CDATA[ 




<p>Social signals generated from users tends to follow a diurnal pattern where there’s activity at certain hours of the day and lulls at others. &nbsp;This pattern is interesting but often it is other patterns that are more salient, like spikes &nbsp;in traffic. &nbsp;When the spikes are combined with the diurnal fluctuations, we have a signal separation problem. &nbsp;In this framing of the problem, the observed web traffic is modeled as an underlying trend signal multiplied by the harmonic noise of daily fluctuations. &nbsp;Multiplication in the time domain is equivalent to addition in the frequency domain. &nbsp;So to recover the underlying trend signal we subtract the average frequency spectrum from the daily observed frequency spectrum.</p>
<p>It turned out that this was an easy problem to solve in R, so I wanted to share my experience. &nbsp;First, to visualize the process below is an example of a snippet of the observed signal over about 3 weeks.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/03/hourly_app_status_snip_raw.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/03/hourly_app_status_snip_raw.jpg" class="img-fluid figure-img"></a></p>
<figcaption>hourly_app_status_snip_raw</figcaption>
</figure>
</div>
<p><a href="../../assets/wordpress/2015/03/hourly_app_status_snip_raw.pdf">hourly_app_status_snip_raw</a></p>
<p>you can see that there are several big spikes as well as smaller daily bumps. &nbsp;The goal is to remove the &nbsp;daily bumps so that we can see underlying trends. &nbsp;To do that, we use the FFT to convert the signal to the frequency spectral domain, average the the daily spectra, then subtract the average from the observed daily spectra. &nbsp;One of the cool things about R is that the FFT is a built in function. &nbsp;However, we had to import a library for the Hamming window. &nbsp;The daily spectra correspond to sliding windows of one day length. &nbsp;The edges of the window need to be rounded to prevent artifacts, which is what the Hamming window is needed for.&nbsp;library(‘e1071’) (line 5) imports the Hamming window and&nbsp;library(zoo) imports ‘rollapply’ (line 2), the function that applies the window across the signal (line 14).</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># needs zoo for "rollapply"</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(zoo)</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># needs e1071 for Hamming window</span></span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'e1071'</span>)</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># load data</span></span>
<span id="cb1-8">th <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv2</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'app_status_report_hourly.csv'</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header=</span>F, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">','</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'time'</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'count'</span>))</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># normalize the data by the maximum</span></span>
<span id="cb1-11">X <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> th<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>count[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(th<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>count)]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(th<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>count)</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># </span></span>
<span id="cb1-14">Xw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rollapply</span>(X,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x){x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hamming.window</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>)})</span>
<span id="cb1-15">Fw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(Xw,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,fft)</span>
<span id="cb1-16">Fw_avg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colMeans</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(Fw)))</span>
<span id="cb1-17">Fw_rem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> Fw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> Fw_avg</span>
<span id="cb1-18">Xw_rem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(Xw,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,fft,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inverse=</span>T)</span>
<span id="cb1-19">X_rem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vector</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mode=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">typeof</span>(Xw_rem),<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(X))</span>
<span id="cb1-20"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span>(i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(Xw_rem)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])){</span>
<span id="cb1-21">  X_rem[i<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(i<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">23</span>)] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> X_rem[i<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(i<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">23</span>)] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Xw_rem[,i]</span>
<span id="cb1-22">}</span>
<span id="cb1-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plot(abs(X_rem),type='l') # the recovered with high frequency artifacts</span></span>
<span id="cb1-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">runmed</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(X_rem), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'l'</span>)</span>
<span id="cb1-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">runmed</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(X), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'l'</span>) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#compare with simple median smoothing</span></span></code></pre></div></div>
<p><a href="https://gist.github.com/abecode/ba31e14ff4d5915ff877">Original code on GitHub Gist</a></p>
<p>The output looks like this:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/03/hourly_app_status_snip_remavgspectrum.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/03/hourly_app_status_snip_remavgspectrum.jpg" class="img-fluid figure-img"></a></p>
<figcaption>hourly_app_status_snip_remAvgSpectrum</figcaption>
</figure>
</div>
<p><a href="../../assets/wordpress/2015/03/hourly_app_status_snip_remavgspectrum.pdf">hourly_app_status_snip_remAvgSpectrum</a></p>
<p>One question that comes up is how this compares to just plain old median smoothing. &nbsp;Median smoothing is already a part of the code to generate the output because it acts as a low frequency filter to remove high frequency artifacts from cutting up and reassembling the signal. &nbsp;But what if we just apply plain old median smoothing to the original smoothing without the FFT. &nbsp;The result of just using median smoothing looks like this.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2015/03/hourly_app_status_snip_onlysmoothing.jpg"><img src="https://abecode.github.io/assets/wordpress/2015/03/hourly_app_status_snip_onlysmoothing.jpg" class="img-fluid figure-img"></a></p>
<figcaption>hourly_app_status_snip_onlySmoothing</figcaption>
</figure>
</div>
<p><a href="../../assets/wordpress/2015/03/hourly_app_status_snip_onlysmoothing.pdf">hourly_app_status_snip_onlySmoothing</a></p>
<p>Subjectively, it seems to me that the FFT frequency subtracted signal shows a bit more resolution and does a better job of removing the DC (constant) component of the signal.</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2015/03/05/fun-with-fft-at-vixlet/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/fun-with-fft-at-vixlet/</guid>
  <pubDate>Thu, 05 Mar 2015 00:00:00 GMT</pubDate>
</item>
<item>
  <title>My New Job at Vixlet</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/my-new-job-at-vixlet/</link>
  <description><![CDATA[ 




<p>My old job analyzing social media (mainly Twitter) at <a href="http://adly.com">Adly</a> disappeared after it was acquired and I started working at <a href="http://vixlet.com">Vixlet</a>. &nbsp;Vixlet’s aim is to connect people with what they are passionate about, which to date has been mainly music (Slipknot) and sports (baseball, football, and tennis). &nbsp;My role there is to do R&amp;D and analytics. &nbsp;It’s been a productive 2.5 months so far and I’ve had a lot of fun (i got to go to London to the Barclay’s ATP tennis tournament for work!). &nbsp;We started a site, <a href="http://labs.vixlet.com" title="labs.vixlet.com">labs.vixlet.com</a>&nbsp;to show demos from our work. One demo is the “<a href="http://labs.vixlet.com:5000">Passion Bot”, a dialog agent to talk about a user’s passions</a>. &nbsp;Another was <a href="http://labs.vixlet.com:5001">a visualization of Twitter traffic about tennis during the Barclay’s ATP tournament</a>. &nbsp;Another demo was a <a href="http://labs.vixlet.com:5002">chatbot for tennis trivia</a>.</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2015/01/06/my-new-job-at-vixlet/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/my-new-job-at-vixlet/</guid>
  <pubDate>Tue, 06 Jan 2015 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Chinese allegory of the cave</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/chinese-allegory-of-the-cave/</link>
  <description><![CDATA[ 




<p>L.A. is a very stimulating city. &nbsp;One way that L.A. is stimulating is that it has a lot of art galleries and exhibitions. Last weekend I went back to the Mike Kelley exhibit at MOCA and I noticed some things that I didn’t see the first time. &nbsp;One of the pictures was about spelunking and a friend, Richard, pointed out that it was about Plato’s <a href="http://en.wikipedia.org/wiki/Allegory_of_the_Cave">allegory of the cave</a>.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2014/06/mike_kelley_spelunking.jpg"><img src="https://abecode.github.io/assets/wordpress/2014/06/mike_kelley_spelunking.jpg" class="img-fluid figure-img"></a></p>
<figcaption>Exploring from Plato’s Cave, Rothko’s Chapel, Lincoln’s Profile</figcaption>
</figure>
</div>
<p>Exploring from Plato’s Cave, Rothko’s Chapel, Lincoln’s Profile</p>
<p>So Plato’s cave was in the back of my mind recently.</p>
<p>Another way L.A. is stimulating is the mix of cultures, languages, and food. &nbsp;I was at the Hong Kong Market mall in West Covina and I saw a Korean restaurant with the Chinese characters &nbsp;<span lang="ko-Hani">明洞</span>, so that sparked my curiosity. &nbsp;It turns out that it’s a town in Korea, <a href="http://en.wikipedia.org/wiki/Myeong-dong">Myeong-dong</a>, written in Chinese characters. When I looked it up in the Chinese dictionary it appeared&nbsp;to be the character for &nbsp;“Bright” &nbsp;and the character for “Cave”</p>
<p><a href="http://www.mdbg.net/chindict/chindict.php?page=worddict&amp;wdrst=0&amp;wdqb=ming" title="Ming">明</a>&nbsp;<a href="http://www.mdbg.net/chindict/chindict.php?page=worddict&amp;wdrst=0&amp;wdqb=ming" class="uri">http://www.mdbg.net/chindict/chindict.php?page=worddict&amp;wdrst=0&amp;wdqb=ming</a><br>
<a href="http://www.mdbg.net/chindict/chindict.php?wdqb=c%3A%2A%E6%B4%9E%2A&amp;wdrst=0#" title="Show information about all characters">洞</a>&nbsp;<a href="http://www.mdbg.net/chindict/chindict.php?wdqb=c%3A%2A%E6%B4%9E%2A&amp;wdrst=0" class="uri">http://www.mdbg.net/chindict/chindict.php?wdqb=c%3A%2A%E6%B4%9E%2A&amp;wdrst=0</a></p>
<p>In the last link, you can see that the character for cave is used in words like “see clearly” and “insight”. &nbsp;This seemed somewhat related to Plato’s allegory of the cave. &nbsp;However, &nbsp;in Plato’s allegory of the cave &nbsp;the insight (seeing how things are rather than just shadows) came from leaving the darkness of the cave, but in Chinese, it seems like insight comes from the meaning of piercing, like a how a cave pierces the mountain (the same character is used in the word for <a href="http://www.mdbg.net/chindict/chindict.php?wdqb=c%3A%2A%E8%80%B3%E6%B4%9E%2A&amp;wdrst=0">pierced ear</a>, <a href="http://www.mdbg.net/chindict/chindict.php?wdqb=c%3A%2A%E9%9A%A7%E6%B4%9E%2A&amp;wdrst=0">tunnel</a>, etc.).</p>
<p>A lot of times it doesn’t make sense to take Chinese characters too literally (this applies to words and expressions in other&nbsp;languages&nbsp;in general), so I’m probably reading into it to much. But it can make the characters&nbsp;more interesting&nbsp;and aid in remembering them.</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2014/06/14/chinese-allegory-of-the-cave/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/chinese-allegory-of-the-cave/</guid>
  <pubDate>Sat, 14 Jun 2014 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Vacation Metrics</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/vacation-metrics/</link>
  <description><![CDATA[ 




<p>When I stepped down from my former position as chief technology officer at Annenberg Innovation Lab, I had many plans for how I would use my free time before I found a new job.&nbsp; It’s not completely a vacation free from cares.&nbsp; I still need to find a new job, learn some new skills, follow up on some publications, and sail to Catalina Island, all of which require some work.&nbsp; Since I’m not getting paid for it, I’m considering it vacation. Still, if I get too laid back I won’t do all that I had planned, so I decided to set some objectives to measure my vacation.&nbsp; Here are my objectives and how I can measure their successful completion.</p>
<ul>
<li><strong>Get a job.</strong>&nbsp; This is my primary goal for my vacation and if I don’t find a job in about two months I would consider this vacation a failure.&nbsp; <strong>Metrics:</strong>&nbsp; right now I’m looking for something that is primarily interesting and fun work, that is in either LA, the Bay Area, or California in general, working with good people, that ideally has something to do with what I studied (natural language processing), and that pays well (in that order). <strong>Outcome:</strong>&nbsp; in progress.</li>
<li><strong>Get in touch with friends.</strong> Luckily one of the first things I did on my vacation was to go to my high school friend, Scott Hagen’s, wedding so I reconnected with a lot of friends then and while I was home in Wisconsin and Minnesota.&nbsp; <strong>Metrics:</strong> the main metric is to get in touch with as many friends as possible and a secondary consideration is being able to meet in person versus just by email or phone.&nbsp; I guess a bonus point would be if getting in touch with a friend helped land a job. <strong>Outcome:</strong> in progress.</li>
<li><strong>Sail to Santa Catalina Island.</strong>&nbsp; Since I’ve had a boat (about a year and a half), Elly, my fiancee, and I been studying to made the 30 nautical mile trip from Marina Del Rey.&nbsp; Sailing on the ocean is a lot more involved than on lakes so I’ve been cautious but now that I have more time to read up and practice I’ve been itching to make the trip.&nbsp; <strong>Metrics:</strong> safely going and returning from Catalina, time taken, and amount of fun had. &nbsp;<strong>Outcome:</strong>&nbsp; Done!&nbsp; Last weekend Elly and I successfully made it to Isthmus/Two Harbors.&nbsp; The outward-bound trip took 10 hours, which was a bit long because we had to divert to Redondo/King Harbor to refuel due to calm winds in the morning.&nbsp; In the afternoon the wind and swell picked up a lot and we got a bit wet from spray.&nbsp; On the way back, it took 7 hours because we were more experience and we were in a hurry to beat the mid afternoon turbulence if it came back. &nbsp; It was calmer on the way back and we had the company of many boats and dolphins.&nbsp; Overall, it was fun despite some white knuckles and white cap waves.</li>
<li><strong>Publications.</strong>&nbsp; While I was working, it was hard to keep up with publishing my dissertation research, so I’m hoping to have time to do that over the vacation. <strong>Metrics:</strong> finish the one paper I have under revisions and start at least one more. <strong>Outcome:</strong> in progress.</li>
<li><strong>Learning new skills.</strong>&nbsp; One of the things I’ve been wanting to learn is Ruby and Ruby on Rails.&nbsp; I also want to refresh my knowledge of web technologies about the new additions to html and css and new frameworks for javascript.&nbsp; <strong>Metric:</strong> working demos of some projects used to learn these new skills.&nbsp; <strong>Outcome:</strong> in progress.</li>
<li><strong>Getting into shape.</strong>&nbsp; When things get busy, for me it’s often exercise that gets put on the back burner.&nbsp; While I’m on vacation I want to exercise more and loose some weight. <strong>Metrics:</strong>&nbsp; frequency of exercise, amount of weight lost. <strong>Outcome:</strong> in progress.</li>
<li><strong>Reading.&nbsp;</strong>I have a bunch of books that I’ve been reading that I need to finish and others that I want to start. <strong>Metrics:</strong> how many of the books I want to read that I actually read. <strong>Outcome:</strong> in progress.</li>
</ul>
<p>&nbsp;</p>
<p><a href="http://linguistlist.org/jobs/get-jobs.cfm?id=18618769" class="uri">http://linguistlist.org/jobs/get-jobs.cfm?id=18618769</a></p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2013/09/11/vacation-metrics/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/vacation-metrics/</guid>
  <pubDate>Wed, 11 Sep 2013 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Analysis of Social Media for NBA Finals</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/analysis-of-social-media-for-nba-finals/</link>
  <description><![CDATA[ 




<p>Here is some preliminary results of some analysis of Twitter data about the NBA Finals between the Miami Heat and San Antonio Spurs. &nbsp;First we tracked tweets containing #spurs, @spurs, and #gospursgo for the Spurs and #miamiheat and @miamiheat for the Heat, based on&nbsp;<a href="http://www.vegau.com/resources/NBA-twitter-hashtags/" class="uri">http://www.vegau.com/resources/NBA-twitter-hashtags/</a>&nbsp;.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="http://homebrew.usc.edu/~abe/nba/finals/game3/stackedAreaChart.html"><img src="https://abecode.github.io/assets/wordpress/2013/06/2013nbafinalsgame3.jpeg" class="img-fluid figure-img"></a></p>
<figcaption>2013NbaFinalsGame3</figcaption>
</figure>
</div>
<p>In this the Spurs won in a blow out, pretty much starting in the second quarter. &nbsp;So far the interesting things I noted were that people tend to tweet during the half time and after the game (7:10 and 8:31). &nbsp;Comparing this game with the <a href="http://homebrew.usc.edu/~abe/nba/finals/game2/stackedAreaChart.html" title="nba finals game 2">previous</a>&nbsp;game, it seems that the winners tended to get more tweets. &nbsp;But that’s not to say that there is causation or even direct correlation b/c we could also say that the home team got more tweets in both cases.</p>
<p>Here are some salient timestamps that Jon and I identified during the game.</p>
<p>6:15-Duncan dunk -Spurs up by 7<br>
6:21-good LeBron James play -Miami coming back<br>
6:49-Danny Green 3 pointer-Spurs go up by 8<br>
6:57-spurs go up by 10<br>
7:01-Neal 3 pointer,Spurs by 11<br>
7:09-heat tie it up<br>
7:10-Neal hits at buzzer spurs up at halftime<br>
7:43-largest spurs lead of the night</p>
<p>7:58: End of third, 758</p>
<p>8:05-Timeout</p>
<p>8:09-Spurs slam dunk<br>
8:10-Spurs 3 point</p>
<p>8:16-Spurs 3 point</p>
<p>8:16-Spurs dunk<br>
8:18-Spurs 3 point<br>
8:22-Heat 3 point<br>
8:22-Time out<br>
8:29-Spurs dunk<br>
8:31-Game over</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2013/06/12/analysis-of-social-media-for-nba-finals/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/analysis-of-social-media-for-nba-finals/</guid>
  <pubDate>Wed, 12 Jun 2013 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Hourly Counts of Movie Tweets Using R</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/hourly-counts-of-movie-tweets-using-r/</link>
  <description><![CDATA[ 




<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2013/01/moviesfrom20130111.png"><img src="https://abecode.github.io/assets/wordpress/2013/01/moviesfrom20130111.png" class="img-fluid figure-img"></a></p>
<figcaption>moviesFrom20130111</figcaption>
</figure>
</div>
<p>In the last post, I aggregated the counts of tweets in python and generated a table that I used in R. &nbsp;This time I wanted to go from the raw input of tweets and the output of sentiment analysis to aggregated hourly counts using R, and this time for movies that came out on Jan 11, 2013 (Gangster Squad, Zero Dark Thirty, and A Haunted House.</p>
<p>Do this in R turned out to be harder than I expected and I had to install some libraries, namely “zoo” (which stands for “z ordered observations”)and “chron”, which can be seen in lines 1-5 in the gist below*. &nbsp;I also had to massage the data a little more than I was expecting. &nbsp;After reading it in (line 8), &nbsp;I had to muck around with making the tweet column be character strings instead of factors, and parsing the date info into a zoo object. &nbsp;Line 20 actually does the aggregation. &nbsp;After plotting it, I noticed a spike on Sunday evening. &nbsp;It turned out there was a lot of (re)tweets about Zero Dark Thirty and one about a ticket give-away for Gangster Squad:</p>
<p>“RT @goldenglobes: Best Actress in a Motion Picture – Drama – Jessica Chastain – Zero Dark Thirty – #GoldenGlobes”<br>
“RT @vuecinemas: Help stop the mob with #GangsterSquad on Jan 10th! To win one of 5 movie packs, follow us and retweet this message by 5p …”<br>
“Woot! RT @Bad_Wobot1013: Awesome Jessica Chastain!! ”</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># install and load additional packages</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"zoo"</span>)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"chron"</span>)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(zoo)</span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(chron)</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># read in data</span></span>
<span id="cb1-8">dt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.delim</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"movieReports/20130109_to_20120113.tsv"</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment.char=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">quote=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.strings=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fileEncoding=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># convert the tweet column from a factor (default) to a character string</span></span>
<span id="cb1-11">dt<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>tweet<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(dt<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>tweet)</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># add a dummy variable for counts</span></span>
<span id="cb1-14">dt<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transform</span>(dt, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dummy=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-15"></span>
<span id="cb1-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># create a zoo object (after many unsuccessful tries)</span></span>
<span id="cb1-17">z <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">zoo</span>(dt<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dummy,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">order.by=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.chron</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(dt<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>postedTime),<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%Y-%m-%dT%H:%M:%OSZ"</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tz=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GMT"</span>))</span>
<span id="cb1-18"></span>
<span id="cb1-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># aggregate by passing a function that uses another R time functionality</span></span>
<span id="cb1-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aggregate</span>(z,<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.POSIXct</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trunc</span>(x,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hour"</span>)) )</span>
<span id="cb1-21"></span>
<span id="cb1-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plot the time series (by default this will open a popup window</span></span>
<span id="cb1-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aggregate</span>(z,<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.POSIXct</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trunc</span>(x,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hour"</span>)) ))</span>
<span id="cb1-24"></span>
<span id="cb1-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># this will change the times to Pacific time, from GMT (perhaps there is a better way)</span></span>
<span id="cb1-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aggregate</span>(z,<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.POSIXct</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trunc</span>(x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>),<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hour"</span>)) ))</span>
<span id="cb1-27"></span>
<span id="cb1-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#this will save the </span></span>
<span id="cb1-29"></span>
<span id="cb1-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># I was interested in a spike that I saw at 2013-01-13 19:00:00:</span></span>
<span id="cb1-31">spike<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span>dt[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.POSIXct</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trunc</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">time</span>(z),<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hour"</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.POSIXct</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2013-01-13 19:00:00"</span>),]</span>
<span id="cb1-32"></span>
<span id="cb1-33"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># this sorts the tweets from the spike by retweet count</span></span>
<span id="cb1-34">spike[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">with</span>(spike,<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(retweetCount)),<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb1-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># output of top retweetedTweets:</span></span>
<span id="cb1-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># [23340] "RT @goldenglobes: Best Actress in a Motion Picture - Drama - Jessica Chastain - Zero Dark Thirty - #GoldenGlobes"                                                   </span></span>
<span id="cb1-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#[23341] "RT @vuecinemas: Help stop the mob with #GangsterSquad on Jan 10th! To win one of 5 movie packs, follow us and retweet this message by 5p ..."                       </span></span>
<span id="cb1-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># [23342] "Woot! RT @Bad_Wobot1013: Awesome Jessica Chastain!! "    </span></span></code></pre></div></div>
<p><a href="https://gist.github.com/abecode/4562764">Original code on GitHub Gist</a></p>
<p>*Note that if you’re using Linux, you’ll need to have the R-devel packages to build this libraries in the installation process</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2013/01/18/hourly-counts-of-movie-tweets-using-r/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/hourly-counts-of-movie-tweets-using-r/</guid>
  <pubDate>Fri, 18 Jan 2013 00:00:00 GMT</pubDate>
</item>
<item>
  <title>2012 US Presidential Election Timeline in Twitter</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/2012-us-presidential-election-timeline-in-twitter/</link>
  <description><![CDATA[ 




<p>I was looking at the spikes in twitter traffic about Obama and Romney during the 2012 US presidential election. So far this is just volumes of tweets containing “obama” and/or (logical or) “romney” (case insensitive), but in the future I would like to do similar plots for sentiment.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2012/12/electiontimeline_annotated.png"><img src="https://abecode.github.io/assets/wordpress/2012/12/electiontimeline_annotated.png" class="img-fluid figure-img"></a></p>
<figcaption>electionTimeline_annotated</figcaption>
</figure>
</div>
<p>The data this is based on 315,000,000 tweets, which was more than 1TB when including all the metadata. &nbsp;Only the subset of these matching “obama” or “romney” were used for the chart, but still it took 11 hours to tabulate the results on my desktop computer (the one that I mentioned in&nbsp;<a href="../../posts/raid-setup/index.html" title="raid setup">the previous post</a>).</p>
<p>This plot was made using <a href="http://www.r-project.org/" title="R">R</a> and <a href="http://inkscape.org/" title="inkscape">Inkscape</a>. &nbsp;Here’s the <a href="http://racer5.usc.edu/~abe/twitterElectionTimeline_tsvWithHeader.txt" title="twitter election timeline">input data table</a>, and here’s a gist of the R code :</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Read in data</span></span>
<span id="cb1-2">timeSeriesElectionData <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.table</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"twitterElectionTimeline_tsvWithHeader.txt"</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Attach columns of data as variables in R environment</span></span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attach</span>(timeSeriesElectionData)</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># open a pdf file for writing</span></span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pdf</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"electionTimeline.pdf"</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plot the sum of tweets about obama and romney, as a line, with no x-axis ticks, bla bla... </span></span>
<span id="cb1-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(obama<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>romney, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'l'</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xaxt=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'n'</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Date'</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Number of Obama and Romney Tweets"</span>)</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># create a sequence of dates, from Mar. 1 to Dec. 1, by month</span></span>
<span id="cb1-14">d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq.Date</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2012-3-01'</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'2012-12-01'</span>),<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'month'</span>)</span>
<span id="cb1-15"></span>
<span id="cb1-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># find the number of data points:</span></span>
<span id="cb1-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(obama)</span>
<span id="cb1-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># output: [1] 1068</span></span>
<span id="cb1-19"></span>
<span id="cb1-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># write the dates as axis ticks</span></span>
<span id="cb1-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">axis</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">side=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels=</span>d,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">at=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">from=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">to=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1068</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length.out=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>),<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cex.axis=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">las=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb1-22"></span>
<span id="cb1-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#close the pdf file</span></span>
<span id="cb1-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span></code></pre></div></div>
<p><a href="https://gist.github.com/abecode/4289867">Original code on GitHub Gist</a></p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2012/12/14/2012-us-presidential-election-timeline-in-twitter/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/2012-us-presidential-election-timeline-in-twitter/</guid>
  <pubDate>Fri, 14 Dec 2012 00:00:00 GMT</pubDate>
</item>
<item>
  <title>raid setup</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/raid-setup/</link>
  <description><![CDATA[ 




<p>I recently got a new computer for work, a 32 GB, 8 core, RAID enabled machine (woohoo!).&nbsp; I wanted to test exactly how fast the RAID-0 setup actually was.&nbsp; Transferring about 820 GB from a USB-3 external HD:</p>
<p>time cp -rp /media/ts-backup-2/data_gnip/ /raid/<br>
real&nbsp;&nbsp;&nbsp; 176m14.507s<br>
user&nbsp;&nbsp;&nbsp; 0m23.533s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 44m27.038s</p>
<p>or about 3 hours, 273GB per hour, 4GB per min., 75MB per sec.&nbsp; I did the same<br>
copy procedure to a regular hdd (7200RPM, bla, bla), and the result was pretty<br>
much the same, which leads me to believe (hope) that the speed was limited by<br>
the usb hdd.</p>
<p>one thing that was taking a lot of time was simply doing wc on all the twitter<br>
log files, so now I’m going to compare running wc on the raid and the regular<br>
hdd:</p>
<p>RAID<br>
time wc /raid/data_gnip/tweets_2*txt<br>
348649707&nbsp; 21225017895 877863706316 total</p>
<p>real&nbsp;&nbsp;&nbsp; 219m18.297s<br>
user&nbsp;&nbsp;&nbsp; 213m20.851s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 5m25.995s</p>
<p>which is about 3 hrs 40 minutes, or about 1.5 million lines (rather big json<br>
records) per minute or 26000 lines per second.</p>
<p>comparing that with the regular hdd:</p>
<p>time wc /data/data_gnip/tweets_2*txt<br>
…<br>
348649707&nbsp; 21225017895 877863706316 total</p>
<p>real&nbsp;&nbsp;&nbsp; 223m9.239s<br>
user&nbsp;&nbsp;&nbsp; 216m21.881s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 6m3.174s</p>
<p>So I’m not really seeing the benefit of RAID at this point.&nbsp; I’m still hoping<br>
that I can find the benefit of RAID.&nbsp; I was thinking that since it is a<br>
sequential read, one file after another, that I might see the benefit with parallel reading:</p>
<p>time find /raid -name “tweets_2*txt” | parallel wc<br>
…<br>
real&nbsp;&nbsp;&nbsp; 67m58.278s<br>
user&nbsp;&nbsp;&nbsp; 425m54.987s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 7m9.929s</p>
<p>So that was a lot faster (3x), and you can see the multiple<br>
core effect in that the user CPU time is higher than the real time.</p>
<p>time find /data -name “tweets_2*txt” | parallel wc<br>
…<br>
real&nbsp;&nbsp;&nbsp; 305m27.366s<br>
user&nbsp;&nbsp;&nbsp; 265m43.306s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 6m49.296s</p>
<p>aha, it finally found a way to see the speedup from RAID. itseems like the<br>
cpu’s in the system monitor are less saturated, and more jagged/noisy.</p>
<p>Still, in the process of waiting for these programs to terminate, I found an<br>
approximate line counter on a forum.&nbsp; It uses a partial line count from<br>
portion of a big file and then extrapolates the approximate number based on<br>
the file size.<br>
<a href="http://www.documentroot.com/2011/02/approximate-line-count-for-very-large.html" class="uri">http://www.documentroot.com/2011/02/approximate-line-count-for-very-large.html</a><br>
Thanks to Erik Aronesty for providing this perl script!</p>
<p>time alc.pl /raid/data_gnip/tweets_2*txt</p>
<p>…</p>
<p>359757377 total<br>
real&nbsp;&nbsp;&nbsp; 0m32.885s<br>
user&nbsp;&nbsp;&nbsp; 0m0.496s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 0m0.800s</p>
<p>which is off by about 10 million out of 350 millon, roughly a factor of less than 10, but faster by about an hour (roughly faster than a factor of 100).<br>
To be complete, here’s the performance of alc.pl on the regular disk:</p>
<p>time alc.pl /data/data_gnip/tweets_2*txt</p>
<p>359757377 total</p>
<p>real&nbsp;&nbsp;&nbsp; 0m36.171s<br>
user&nbsp;&nbsp;&nbsp; 0m0.639s<br>
sys&nbsp;&nbsp;&nbsp;&nbsp; 0m0.684s</p>
<p>VERDICT: Raid is definitely faster if you use it wisely, but if you just want an approximate line count, you can save a lot by just using a clever perl script. Of course I’ll be doing more than counting lines, so the raid should come in handy in the future, but it’s definitely possible to over engineer things if I’m not careful.</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2012/11/07/raid-setup/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/raid-setup/</guid>
  <pubDate>Wed, 07 Nov 2012 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Interspeech 2012, Day 4</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/interspeech-2012-day-4/</link>
  <description><![CDATA[ 




<p>Today, the keynote speaker was Garet Lahvis, who presented on analyzing prosody in ultrasonic rat vocalizations. &nbsp;I found this pretty interesting. &nbsp;Even though the signal processing aspect of the study was very basic, the novel part is looking at animals instead of humans, and (non-human) lab rats that have been removed from their natural environment for several generations. &nbsp;Also, an interesting aspect of this study is the implication for emotion research. &nbsp;One of the interesting findings is that for a certain strain of rats, b6, positive valence emotion vocalization recordings had similar effects on other rats as food and morphine, and similar for negative valence events like foot shocks. &nbsp;Another strain of rats, BALB, had less response to emotional vocalizations from other rats. &nbsp;This study had implications for both substance abuse studies and autism research.</p>
<p>One of the interesting posters I saw was on building speech recognition language models from twitter.</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2012/09/13/interspeech-2012-day-4/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/interspeech-2012-day-4/</guid>
  <pubDate>Thu, 13 Sep 2012 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Interspeech 2012, day 3</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/interspeech-2012-day-3/</link>
  <description><![CDATA[ 




<p>Today the keynote speaker was Michael Riley from Google, who talked about openfst and some of the new aspects of their work. &nbsp;Most of the talk was a bit too basic for people that know about fst’s and to advanced for people who don’t, but it was still interesting as a refresher. &nbsp;I was most interested in the push-down automata/transducers that they added to openFST recently. &nbsp;Also, the discussion about some of the tradeoffs in the design of FSTs was interesting, e.g., time vs. space, static vs.&nbsp;dynamic machines, and centralized vs.&nbsp;distributed algorithms. &nbsp;Also, the discussion about the different types of artificial languages and how they relate to parser types was interesting. &nbsp;The idea was that with a pushdown automaton, the determinization/minimization/epsilon removal is no longer unique and different strategies result in different types of parsers, like Early, Cyk, etc. &nbsp;I think I would get more out of this talk if I refreshed my knowledge of parser types.</p>
<p>One of the sessions that caught my attention was the language modelling session. &nbsp;I missed the talk on paraphrastic language models, but I read some of the paper and it seems very promising to read in more detail. &nbsp;The IBM talk on neural network language models was interesting and it was pretty funny that some of their models took 50 days to train. &nbsp;The main results for this work were training speedups rather than performance increases. &nbsp;The low rank plus sparse talk was also very compelling model and interesting talk. &nbsp;I want to reexamine some of my work in light of this (the fuzzy logic model of emotion dimensions seems analogous to the &nbsp;continuous low-rank component, and the emo20q question-answer based model analogous to the discrete, sparse component).</p>
<p>The reception at the Portland art museum was very nice. &nbsp;The museum was had a lot of beautiful art and there was a tango &nbsp;band in the upstairs ballroom that I enjoyed with a researcher from Toyota that was a Tango fan. &nbsp;Here are some pictures of the reception.</p>
<p><a href="../../assets/wordpress/2012/09/2012-09-12-19-27-36.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-12-19-27-36.jpg" class="img-fluid"></a><br>
last week I actually visited where the original Venus/Aphrodite de Milo was found (Milos Island, Greece)</p>
<!-- -->
<p><a href="../../assets/wordpress/2012/09/2012-09-12-20-22-40.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-12-20-22-40.jpg" class="img-fluid"></a><br>
Tango band</p>
<p><a href="../../assets/wordpress/2012/09/2012-09-13-01-17-43.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-13-01-17-43.jpg" class="img-fluid"></a></p>
<p><a href="../../assets/wordpress/2012/09/2012-09-13-01-18-19.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-13-01-18-19.jpg" class="img-fluid"></a></p>
<p>After the reception, the sailers went out for drinks. &nbsp;Here are some of the pictures that are fit for the public 🙂</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2012/09/2012-09-12-19-27-36.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-12-19-27-36.jpg" class="img-fluid figure-img"></a></p>
<figcaption>last week I actually visited where the original Venus/Aphrodite de Milo was found (Milos Island, Greece)</figcaption>
</figure>
</div>
<p>last week I actually visited where the original Venus/Aphrodite de Milo was found (Milos Island, Greece)</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="../../assets/wordpress/2012/09/2012-09-12-20-22-40.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-12-20-22-40.jpg" class="img-fluid figure-img"></a></p>
<figcaption>Tango band</figcaption>
</figure>
</div>
<p>Tango band</p>
<p><a href="../../assets/wordpress/2012/09/2012-09-13-01-17-43.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-13-01-17-43.jpg" class="img-fluid"></a></p>
<p><a href="../../assets/wordpress/2012/09/2012-09-13-01-18-19.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-13-01-18-19.jpg" class="img-fluid"></a></p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2012/09/12/interspeech-2012-day-3/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/interspeech-2012-day-3/</guid>
  <pubDate>Wed, 12 Sep 2012 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Interspeech 2012, day 2</title>
  <dc:creator>Abe Kazemzadeh</dc:creator>
  <link>https://abecode.github.io/posts/interspeech-2012-day-2/</link>
  <description><![CDATA[ 




<p>Today the key note speaker was Roger Dannenberg, who presented about music understanding and the future of music performance. &nbsp;It was a pretty interesting talk and it even included him playing his trumpet in a demo. &nbsp;It included both instrumental and speech/voice based applications and presented a good point about how big a market this area is.</p>
<p>I didn’t make any notes about the presentations today but I was asked to be a reporter for the student industry academic lunch (that is why I decided to blog about the rest of the conference in the first place–glad I did b/c it helps to reinforce the memory of all the things that I saw, even though it was a bit of work).</p>
<p>The student lunch at the table I was assigned to was hosted by Murat Saraclar (Google and Bogazici University) and Gareth Jones (Dublin City University) and the topic of discussion was spoken term detection and spoken document retrieval. &nbsp;The students that were attending were: Tsung-Hsien Wen (National Taiwan University), Deepak Krishnarajanaga Thotappa (IIT Guwahati), &nbsp;Haiyang Li (Harbin Institute of Technology), Atta Norouzian (McGill), Hungya Lee (National Taiwan University), Maria Eskevich (Dublin City University), and myself, Abe Kazemzadeh (USC SAIL Lab). We spent most of the time doing introductions and learning about each other’s research, but later it became more of a conversational discussion. &nbsp;Some topics that came up in the discussion were:</p>
<ul>
<li>the differences between term detection and document retreival</li>
<li>differences in data sources, e.g., broadcast news vs.&nbsp;meeting data</li>
<li>discriminative language models</li>
<li>the work of Amit Singhal at Google</li>
<li>Malach corpus of spoken video interviews</li>
<li>an <a href="http://www.nist.gov/manuscript-publication-search.cfm?pub_id=151423">older NIST overview paper on spoken document retrieval</a></li>
</ul>
<p>Here are some pictures of the student lunch:</p>
<p><a href="../../assets/wordpress/2012/09/2012-09-11-13-22-26.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-11-13-22-26.jpg" class="img-fluid"></a></p>
<p><a href="../../assets/wordpress/2012/09/2012-09-11-13-22-50.jpg"><img src="https://abecode.github.io/assets/wordpress/2012/09/2012-09-11-13-22-50.jpg" class="img-fluid"></a></p>
<p>Also, today was the student reception at the crystal ballroom. &nbsp;I got side-tracked and ended up at a concert by Tango Alpha Tango at the crystal hotel, which was next to the place that I was supposed to go. &nbsp;The concert was pretty good and I did finally make it to the tail end of the student reception. &nbsp;The dance floor of the crystal ball room was on springs or something, so it was almost like a trampoline. &nbsp;Unfortunately no one was dancing.</p>
<hr>
<p>Originally published on <a href="https://abewrites.wordpress.com/2012/09/11/interspeech-2012-day-2/">abewrites</a>.</p>



<p>clustrmaps.html</p> ]]></description>
  <category>Uncategorized</category>
  <guid>https://abecode.github.io/posts/interspeech-2012-day-2/</guid>
  <pubDate>Tue, 11 Sep 2012 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
