20time the 9th

I’ve made decent progress in the past few weeks, despite the onslaught of AP tests.

I have the basic architecture of the tic tac toe neural network code, and ended up settling on using a genetic algorithm to evolve it, and also coded that up. However, debugging neural nets is a pain, especially when you decide to use genetic algorithms (they take forever to improve), so I decided that I got what I wanted from the mini-project (the basic understanding of how neural nets work, and how to implement them), and set it aside for now to work on the actual final product. 

 

My final product is creating a neural network that generates music. I did some research, and it looks like LSTMs are my best bet. These are a type of recurrent neural network (RNN), where outputs at a certain time are fed back in for the next “iteration” of the network, so the network’s outputs at one time are dependent of those at previous times, which is necessary when you want to predict what the next note should be in a musical passage.

(^RNNs, the hidden state at time T-1 gets copied over to be plugged in for the hidden state at time T)

LSTMs, in particular, are capable of “remembering” information for long periods of time (that’s why they’re called Long Short Term Memory networks). LSTMs have been used frequently for generating text of a certain style (whether it be Shakespeare, or LaTeX syntax), but they can also be used for music generation, by converting a music file to text format, and plugging it in.

My goal for this week is to find a fast way to convert the music files to some text format (will probably be going with abc notation or some similar ASCII format), and also getting most of the LSTM coded. It’ll take a while for it to train (this guy  who used what he calls a Biaxial RNN to make music apparently paid money for Amazon’s webservices to run his network…) but I think it’ll be sufficient to have it train overnight for a few days. I am slightly concerned that, as I mentioned above, debugging will take a while (especially when it takes so long to see if the network actually improves). Hopefully that won’t be a problem. Also, I’m going to start setting up a website explaining how this, along with other machine learning algorithms, works.

The Last Mockingbird

Harper Lee did a really nice job with the ending. On Page 279, Scout recaps everything that happened over the past few years, but from Arthur Radley’s perspective.

Brief excerpts:

“It was fall, and his children fought on the sidewalk in front of Mrs. Dubose’s. The boy helped his sister to her feet and they made their way home. Fall, and his children trotted to and fro around the corner, the day’s woes and triumphs on their faces. They stopped at an oak tree, delighted, puzzled, and apprehensive. “

“Atticus was right. One time he said you never really know a man until you stand in his shoes and walk around in them. Just standing on the Radley porch was enough.”

The book often contrasted Jem’s newfound “maturity” with Scout’s naivety, but this quote demonstrates how much Scout has grown through the book. Before, Jem had to explain to her why she couldn’t brag about Atticus’s shooting abilities at school. But, later, she is able to understand that Boo Radley killed Mr. Ewell, and that they must conceal that with the lie that Mr. Ewell killed himself. Scout is able to put herself in Arthur Radley’s shoes, and understand his perspective, from the secret life she’s always been curious about.

I also found it interesting how, on page 278, Scout mentions, after walking Boo back to his house, “I never saw him again.” I would think that this might be the beginning of Boo’s return to society, but I suppose that might be against his brother’s wishes – and, as Jem noted, he wanted to stay inside, only coming out when his children needed him.

Through the several years, Jem evolved –  from a child, to a teen, and finally to a young adult. His core characteristics have been bravery and moral righteousness, though the latter sometimes came across as arrogance, especially in his interactions with Scout, in which Jem often tells her what she should do. However, near the end of the book, Scout notes that, “Jem was becoming almost as good as Atticus at making you feel right when things go wrong “ (pg 259). This shows that he is gradually moving away from that arrogance, and is getting better at empathizing with people.

Compared to the other characters, Jem was affected significantly by the Tom Robinson case, perhaps even more than Atticus was. He legitimately believed that the jury would evaluate the evidence just as Jem did, and make a decision in a manner he considered “fair”. Ong pg. 212, “It was Jem’s turn to cry. His face was streaked with angry tears as we made our way through the cheerful crowd. ‘It ain’t right, ‘ he muttered.” Having been raised by Atticus, and being around people like Miss Maudie, Jem was probably under the impression that more people were fair (availability heuristic type thing), i.e. evaluated evidence without regard to race – it came as a nasty shock to him that most people in the town didn’t think like he did. This came as a challenge to his innate sense of what is good. Previously, he alludes to the fact that he wants to become a lawyer, just like Atticus. I wonder if this’ll inspire further him to join Atticus in doing what the rest of the town is too afraid to do.

In class, we discussed who killed Bob Ewell. The general consensus was that it was Boo Radley. On page 276, Mr. Tate says, “Mr. Finch, taking the one man who’s done you and this town a great service an’ draggin’ him with his shy ways into the limelight – to me, that’s a sin. It’s a sin and I’m not about to have it on my head. If it was any other man it’d be different. But not this man, Mr. Finch.” The “shy ways” part really points to Boo, as opposed to, say, Jem. Furthermore, Atticus thanks Boo for his children before he leaves.

We also discussed why To Kill A Mockingbird is considered a “simple love story”. Some of us suggested that it showed how love was shown in many forms – between Atticus and his children, Scout and Dill, Atticus and Aunt Alexandra, Scout/Jem and Calpurnia, etc. But, also, the book could be considered a lovestory between Scout and Boo Radley. Scout is shown fantasizing about seeing him – “Maybe someday we would see him. I imagined how it would be: when it happened, he’d just be sitting in the swing when I came along. ‘Hidy do, Mr. Arthur.’ “ Much of her (and Jem and Dill’s) childhood is spent drawing him out of his house. And in the end, Boo saves her life. Ultimately, it’s Boo that teaches Scout true empathy, just as it was Mrs. Dubose that taught Jem empathy.

In our second discussion, we also introduced the ideas of William James’s  “On a certain blindness in human beings.” We’re blinded by feelings – whenever we evaluate something, the feeling it evokes dominates our judgement, perhaps afterwards we rationalize it with seemingly logical arguments. We’re also blinded by our inherently biased perspective in life – everything is juxtaposed with our own experiences and what we feel is important, making it difficult to truly empathize with others. To Kill a Mockingbird was narrated by a child, and, as Mr. Dolphus Raymond noted, “Because you’re children and you can understand.” As a child, Scout is more accepting and understanding of others. Furthermore, because of this fact, people like Boo and Mr. Raymond tend to be more open with them.

This blindness, however, permeated the society in several forms  – first, in the form of inaction. In HPMOR, Professor Quirrell mentions, “When you are older, you will learn that the first and foremost thing which any ordinary person does is nothing.” This is especially true in Maycomb, where the citizens depend on Atticus to do what is right. Whether they subscribe to the Jim Crow ideas ingrained in society, or live in fear of breaching that very code, they rationalize their lack of action or advocacy in racism in some way, that is likely not consistent with their morals. Even today, James’s blindness persists. Perhaps it’s even become enhanced, as our lives become more well-documented with the rise of social media, and it becomes ever-important to shield yourself with a facade as you become visible to millions of others, making true empathy a difficult task.

Mockingbirds #2

Throughout chapters 10 to 14, inclusive, in Harper Lee’s To Kill A Mockingbird, I found Atticus’s character intriguing. He seems uncommonly sane, especially in the way he handles Jem and Scout (e.g. keeping certain aspects of himself hidden from them, having Jem read to Mrs. Dubose, etc.) This is further shown in his insistence of defending an African American as a lawyer, despite the negative response to that move. This section also revealed the meaning of the title, on page 90: “Mockingbirds don’t do one thing but make music for us to enjoy. They don’t eat up people’s gardens, don’t nest in corncribs, they don’t do one thing but sing their hearts out for us. That’s why it’s a sin to kill a mockingbird.”

Jem experiences a lot of growth in these few chapters, and his maturity is reflected in his ability to understand events that his sister fails to be moved by. For instance, on page 98, after learning that their father was the “deadest shot in Maycomb county”, Scout is eager to have something to tell her schoolmates about her father, but Jem stops her, realizing that Atticus probably had his reasons for keeping that to himself. And later on, after Atticus forces him to read to Mrs. Dubose for a month, and learns of her condition, he begins to empathize with her, understanding how brave she actually was. This is shown in the last sentences of part 2: “ “Jem picked up the candy box and threw it in the fire. He picked up the camellia, and when I went off to bed, I saw him fingering the wide petals.” (The camellia was sent to Jem by Mrs. Dubose, shortly before she died.)

But, despite his shows of maturity, he is still a pubescent pre-teen, and starts to grow distant from Scout (pg 135, “he was positively allergic to my [Scout’s] presence in public”), and he also grows arrogant in thinking himself more adult-like, which was shown by his revealing Dill to Atticus, when he was trying to remain hidden. Also, on page 99, Jem says, “Atticus is a gentleman, just like me!” This seems to imply that Jem looks up to Atticus, “gentleman” perhaps referring to Atticus’s ability to uphold his morals, and his uncommon sanity in a town of many lacking in that area. The latter part refers to Jem’s belief that he, too, knows what is right, and is demonstrated by the many times he tries to tell Scout what to do.

In class, our discussion brought up the Mockingbird quote at the beginning, and some suggested it might refer to African Americans, who weren’t harmful to anyone, yet were looked down upon by some in the town. This might also refer to Boo Radley, who, while he did actually harm someone, seemed to be trying to connect with the outside world in a positive manner (giving Scout the blanket), but was constantly thwarted by his brother. Also, Boo Radley’s character hasn’t played much of a role in these chapters, I wonder if he will return? Dill is back, after all, but Jem will likely choose not to partake in any of Dill’s Boo Radley schemes. We also discussed Atticus’s character in Chapter 10. In the beginning, he was emphasized as feeble and old, yet it was revealed that he had a talent in shooting. Scout is impressed by this, and wished to share this knowledge with her schoolmates. However, we came to the conclusion that Atticus likely kept this hidden from them to separate the ideas of strength and courage from a man with a gun. I think Jem recognized this lesson, with his ending comment on Atticus being a gentleman, recognizing Atticus’s mental fortitude, especially concerning his sense of righteousness.

I am curious, however – the mockingbird quote is definitely foreshadowing, and I think it might relate to Jem’s broken arm. But will Jem be contributing to killing the “mockingbird”, or protecting it? Also, will Jem continue to look up to his father as a gentlemen, or might his arrogance grow to the point that he starts to contradict Atticus?

 

20Time Week #8

This week I started working on the neural network for playing Tic-Tac-Toe. I already have the basic structure from following the handwriting recognition neuralnet from the textbook, so now I’m trying to figure out a good way to train the network. Through research and thinking, I’ve found several approaches – having the network play against a perfect tic-tac-toe AI (I made one from compsci class that I can use), creating all possible configurations and optimal moves, and training the network until it chooses those moves – but these, while technically using a neural network, basically have it copying an existing method. I was thinking of having a population of neural networks and evolving them with a genetic algorithm, but am still thinking of a good metric of “fitness” (how good each neural network is). I think I’ll be able to finish this in the next few days, and then I’ll decide on the final project, which will be tackling a harder problem…which I have yet to decide.

Ah, so we also have to write up a research paper on this project. I had several driving questions for it from week 4: “How do machines learn? What role do humans have in an increasingly automated society? What is intelligence?” The overarching theme of the paper will be the rising presence and future implications of AI within society, and what it means for us to be intelligent. There is a surprisingly large amount of information on this topic, because it’s such a new field that is so powerful. In fact, this video just got released today, and I eagerly await waitbutwhy’s post on Elon Musk’s new company Neuralink, which will be released this week.

To Kill A Mocking Bird #1

We recently started reading To Kill A Mocking Bird by Harper Lee in English class.

One of the major themes of this book is personal growth via greater understanding and development of yourself, and perhaps more important, greater understanding of other people. Atticus explains this idea to Scout (on pg 30), “You never really understand a person until you consider things from his point of view – until you climb into his skin and walk around in it.” There are a number of characters that Scout disagrees with. For instance, her teacher Miss Caroline (didn’t let her read/write), Walter Cunningham (poured molasses all over his food), and most notably, Jem (this happened often, one example was when he and Dill decided to go look through the Radley’s window).

In all of these cases, looking from that person’s perspective would’ve allowed Scout a greater understanding – e.g. in the case of her teacher, being new and in an unfamiliar state, as well as being forced to teach with, as Jem calls it, the “Dewey Decimal System”, if any child acts as an outlier in any manner (e.g. being able to read/write before they are taught in school), the simplest solution is to pretend that that is not the case (i.e. by forbidding the child to do such). Of course, this is a terrible solution, but Scout might understand that this was the result of the school system itself, and Miss Caroline’s lack of experience in teaching, as opposed to an attack on her person.

(^from the To Kill a Mocking Bird movie)

In class, we were each assigned a character to keep track and and empathize with – I kept track of Jem. Jem is Scout’s older brother (by 4 years). One of the things I found most interesting was Jem’s “obsession” with the Radley’s. This “game” of trying to make Boo Radley come out of his house was inspired by Dill, though Atticus eventually forbade it – on pg. 49, “I’m going to tell you something and tell you one time: stop tormenting that man.” However, soon after, on pg 51, “Dill and Jem were simply going to peep in the window with the loose shutter to see if they could get a look at Boo Radley.” However, later, Jem goes back to the Radleys to retrieve his pants, so his father wouldn’t know he went back to the Radleys.  And he knew that Nathan Radley had a nonzero probability of shooting him. In fact he stated, “Atticus ain’t ever whipped me since I can remember. I wanta keep it that way.”

It is clear that Jem admires Atticus, and would rather die than disappoint him – then what inspired him to go back to the Radleys in the first place? Certainly Dill isn’t that convincing. Later on, after the incident, he and Scout find a number of items in a knothole of a tree at the Radley place, which he likely knew were placed there by Boo Radley. After Nathan fills the whole, “He [Jem] stood there until nightfall, and I waited for him. When we went in the house I saw he had been crying; his face was dirty in the right places, but I thought it odd that I had not heart him.” I think Jem was drawn by the secrecy of Boo Radley’s life, and his curiosity got the better of him. But, with the presents, and later the blanket Boo placed on Scout, he gradually understood what Boo’s life was actually like – with emotional abuse by his father, and Nathan continuing his isolation (e.g. filling up the hole with cement), and Jem began to feel sympathy for him.

In class, we had a discussion about this section of the book, and I was intrigued by the idea that all the characters, not just Boo, led secret lives. Both Jem and Scout hid things from their father – we only know them because the story is told from Scout’s perspective. More interestingly, while Atticus remains open and transparent with his children, it is likely that he has the “largest” of the secret lives. Being a lawyer, he is skilled in controlling what knowledge he imparts to others – at the end of Chapter 9, Scout reflects back on her realization that her “eavesdropping” on Atticus and Uncle Jack’s conversation wasn’t what it seemed – Atticus intended Scout to hear the words he said, demonstrating his great control over what he reveals to his children. This therefore would imply he has a very skilled control in hiding things from them, appearing open and transparent while doing so.

Now, I have a few questions. First, Jem and Scout have been noticeably drifting apart – e.g. with Jem and Dill becoming closer friends, and leaving Scout out. How will Jem’s entrance into his teen years impact their relationship? Secondly, perhaps Boo was kind toward Jem and Scout because they expressed interest in him, and he saw that as an opportunity to connect with the external world. How will he do that now, as Jem and Scout will likely follow their father’s advice now, and with the knot hole filled up?

Meta-belief

Strange, that we grow attached to beliefs, when their purposes of modeling reality and guiding our decisions should keep them in constant flux. The Adventures of Huckleberry Finn is a tale of a boy confronting this very issue. As Huck travels alongside a runaway slave on the Mississippi, he struggles to reshape his unyielding beliefs, as each excursion of their journey shines the light on another cross section of the elusive truths of society. With this novel, Mark Twain enlightens the reader as he, alongside Huck, guides America on a journey toward pragmatism over romanticism. At the heart of this lies the ability to form beliefs true to one’s volition, avoiding the cognitive death spirals that litter the fabric of society.

If that fabric represented spacetime, religion would be a black hole. It exerts a very strong influence on the beliefs of those that venture near it. And Twain pokes many holes in this particular institution, especially during Huckleberry’s encounter with the Grangerford and Shepherdson households. Huck describes their common religious practices as “pretty ornery preaching – all about brotherly love, and such-like tiresomeness; but everybody said it was a good sermon, and they all talked it over going home, and had such a powerful lot to say about faith and good works, and free grace, and preforeordestination,” when but page earlier, Huck listened to Buck describe the ongoing feud between the two families: “A feud is this way. A man has a quarrel with another man, and kills him; then that other man’s brother kills him; then the other brothers, on both sides, goes for one another; then the cousins chip in – and by-and-by everybody’s killed off and there ain’t no more feud. But it’s kind of slow, and takes a long time” (Twain 130).

Buck’s family says one thing, and acts a different way. They’re blatantly hypocritical, but how can we explain this? They have two different sets of beliefs. The “brotherly love” is a belief that they believe they should have for the sake of “virtue” or moral “righteousness”, but this belief set, as a model of reality, is neglected. In other words, it is a “belief in a belief” (Yudkowsky). The second set of beliefs they have about the necessity of the feud’s existence can be described as an “anticipatory belief”. It is what they use to actively anticipate the future, and to decide what they should do next. Twain demonstrates here that religion often forms these weaker “belief in beliefs” that are only practiced on the surface, perhaps by nature of the way beliefs are passed down to its followers, failing to instill the societal morals it holds so highly, and therefore failing to prevent bloodbaths like the aforementioned feud, which could have been prevented if any one of the Grangerfords decided to look at the feud through the lens that religion’s morals provided. But, of course, as a set of “belief in beliefs”, those morals were never applied rigorously against more fundamental beliefs. Therefore, the author reveals the necessity of having one’s “anticipatory beliefs” applied to the world in a way that conforms with what you see as “virtuous” and “right”. This is intertwined with the concept of pragmatism, which posits that something’s meaning is “found in the practical consequences of accepting it” (“Stanford Encyclopedia of Philosophy”). In this case, an anticipatory belief should be adopted if accepting it allows to make better decisions and more accurate view the world.

Speaking of pragmatism,

Mark Twain then demonstrates to society the beginnings of a resolution to this issue, through Huck’s character. Huck’s “conscience” berates him multiple times for aiding Jim in his escape, with harsh words such as, “What had poor Miss Watson done to you, that you could see her nigger go off right under your eyes and never say one single word? What did that poor old woman do to you, that you could treat her so mean?” (Twain 109). But towards the end, when Huck is about to send a letter to turn Jim in, “But the words wouldn’t come. Why wouldn’t they? It warn’t no use to try and hide it from Him. Nor from me, neither. I knowed very well why they wouldn’t come. It was because my heart warn’t right; it was because I warn’t square; it was because I was playing double. I was letting on to give up sin, but away inside of me I was holding on to the biggest one of all. I was trying to make my mouth say I would do the right thing and the clean thing, and go and write to that nigger’s owner and tell where he was; but deep down in me I knowed it was a lie” (Twain 241).

Here, Huck describes his own hypocrisy, and it appears that he believes he has the anticipatory belief that handing in Jim is right. However, he then rejects this, with a swift, “All right, then, I’ll go to hell” (Twain 242). Huck’s actions – his anticipatory beliefs – were truly based in altruism, but his society instilled in him a set of beliefs about slaves, and another belief in belief that it is virtuous to uphold that set of beliefs. This second set of beliefs presents itself as his “conscience”, and is important because, otherwise, Huck could simply set it aside as he does with the rest of “sivilized” society. It can be hypothesized that Huck only has this belief because it is the only belief shared by both “sivilized” society, and the uncivilized teachings of his father. In the end, Huck set these beliefs aside pragmatically, as the consequence of keeping them would be to invalidate the real life experiences he had with Jim.

Overall, Huck’s existential turmoil is used by the author to demonstrate a change everyone, and the system itself, must go through, in order to function better as individuals, and as a collective. It allows us to understand what actually underlies our beliefs and actions, and being able to use this knowledge actively, rather than having everyone reflect back to society a rose-tinted image of itself, a dysfunctional state of affairs that make something like slavery sound plausible to the masses.

Therefore, Huckleberry Finn reveals profound observations about the hypocritical nature of our societal beliefs, and hints at ways we might approach this problem. With his mockery of religion, Twain shows how people’s actions contradict the “beliefs” they preach to others, showing that religion often yields the more sinister “belief in belief” that is a mere belief in the virtue of appearing to have a certain belief. And, with Huck’s internal conflict over his beliefs of “slavery”, the author shows how Huck confronts a “belief in belief”, and is able to reinstate altruism as his true (anticipatory) belief. Ultimately, through the consistent clash of realism and romanticism throughout the novel, the author reveals the path that our society should follow. Only pragmatism will allow us to forge beliefs that accurately represent both our inherent beliefs of what is right, and reality itself.

Week 6

Didn’t have a lot of time this week, but I continued reading through the neural networks textbook I linked in the earlier post. Regarding the handwritten digits problem – I initially thought it would be very difficult, but the first chapter of that book worked through a solution of merely 74 lines of code, and no new fancy libraries.

It used sigmoid neurons, which are neurons that, unlike perceptrons, output a real number between 0 and 1 (instead of either 0 or 1), and have the advantage that slightly modifying weights/biases of the artificial neurons doesn’t drastically change the outcome, and fed every pixel of the 28×28 image in as an input, with one hidden layer, and a set of 10 outputs labeled 0 to 9, the greatest of which would be which digit the image showed. So, to recognize the digits, it used the MNIST database for handwritten digits (it has some ten thousand) as a training set, fed them into the network with initially randomized weights and biases, and then used the gradient descent algorithm I mentioned in a previous post to change the weights/biases to make the predictions more accurate. This method led to an accuracy of 95%.

Here’s a picture of the neural net:

I might consider expanding it to letters and applying this to a general handwriting recognition program, but first I’d have to find a database of handwriting, and, also, I was planning on writing a tic-tac-toe neural net, so I might not have the time for that. (Perhaps that could be the final product instead? Would actually present a challenge, especially with separating letters within each word, since, like with my handwriting, some letters are merged together).  Speaking of things I need to do, I’m also working through this example of a genetic algorithm that solves a variation on the 24 game (and maybe I’ll implement one for the 24 game as well).

Pertaining to a mentor for this project, my dad’s a statistician, and he’s used some machine learning algorithms like Random Forest to analyze data, so I think he could act as a mentor. There’s also the coursera course, though I haven’t used it much recently, as the neural net textbook seemed more interesting.