Blog

Day 134: Sunday Coding

It is hot and sunny today. I now have air conditioning this year. I decided that I had other interesting things to do than to melt outside. I stayed inside most of the day. I have to admit I did not get dressed until mid-afternoon.

And what created this lack of attention to the same Sunday process for months, you ask? Back to some Python coding and writing more machine learning code. So just pounding away on my Apple laptop for hours and hours.

Breakfast was the end of the Einstein bagels (they are good for about three days) and a banana. While I worked on getting my Apple back to top class, the morning and part of the afternoon vanished. First, PyCharm, my goto editor for Python, needs to be upgraded. I then needed to use Anaconda, Python update software, to upgrade all of my Python libraries. Not surprisingly, Anaconda needed an upgrade. Then I discovered that Anaconda would not load the machine learning libraries I wanted to use, keras, to handle the machine learning. This is from the examples, and I am not really ready for keras.  Of course, tensor flow is needed as keras uses tensor flow to perform the process.

I have to load most of the changes one at a time. I do manage to have Anaconda update my science libraries. I finally get to coding.

I harvest from my last big python program from eighteen-months ago my standard header and set-up. I like to use a header with all the system values that name versions and developers set. I also like to printout the versions, and the time a program takes to run. So I harvest all of that.

I find a warning that one of my libraries is out-of-date and growl at Anaconda and fix that too.

The day before I attended a Meet-up via Zoom with Knowledge Mavens that had Darren show us a basic machine learning example of how to make a neural network predict a number from hand-written numbers. I wanted to get that working.

As usual, with Python machine learning, it all went sideways. I could not get the libraries to load that had the examples, mnist is a set of files of images of handwritten digits. I searched Stack Overflow, the source of all knowledge for writing Python on the Internet, and found a hint. Yes, my new version of keras had overwritten mnist with a special keras version. So I found a new example and mixed and matched Darren’s code from yesterday with another example using keras version of mnist. At about 3:30PM, I had a working example.

My example code can predict handwritten digits to 97%. I was happy to get back to Python and faced down all the challenges. I did play with the setting in the neural network and managed better and worse results. My program runs in about thirty seconds and runs ten epochs.

#!/usr/bin/env python
"""
    Copyright 2020 by Michael Wild (alohawild)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

==============================================================================


"""
__author__ = 'michaelwild'
__copyright__ = "Copyright (C) 2020 Michael Wild"
__license__ = "Apache License, Version 2.0"
__version__ = "0.0.1"
__credits__ = "Michael Wild"
__maintainer__ = "Michael Wild"
__email__ = "alohawild@mac.com"
__status__ = "Initial"

from time import process_time
import sys
import numpy as np
import keras
from keras.datasets import mnist
from keras.layers import Dense
from keras.models import Sequential
from keras.preprocessing.image import array_to_img
from keras.utils.vis_utils import plot_model
from keras.utils import np_utils

# ######################## shared ##############################

def run_time(start):
    """
    Just takes in previous time and returns elapsed time
    :param start: start time
    :return: elapsed time
    """
    return process_time() - start


def view_image(img):
    img1 = np.expand_dims(img, 2)
    pil_img = array_to_img(img1)
    pil_img.show()

# ****************************************************************

# =============================================================
# Main program begins here


if __name__ == "__main__":

    begin_time = process_time()

    print("Program Numl.py")
    print("Version ", __version__, " ", __copyright__, " ", __license__)
    print("Running on ", sys.version)
    print("Version numpy     :", np.__version__)
    print("Version keras     :", keras.__version__)

    # Load images from models
    (X_train, y_train), (X_test, y_test) = mnist.load_data()

    # flatten 28*28 images to a 784 vector for each image
    num_pixels = X_train.shape[1] * X_train.shape[2]
    X_train = X_train.reshape((X_train.shape[0], num_pixels)).astype('float32')
    X_test = X_test.reshape((X_test.shape[0], num_pixels)).astype('float32')

    # Normalize the model images.
    train_images = (X_train / 255) - 0.5
    test_images = (X_test / 255) - 0.5

    # Flatten the images.
    train_images = train_images.reshape((-1, 784))
    test_images = test_images.reshape((-1, 784))

    # get labels
    train_labels = np_utils.to_categorical(y_train)
    test_labels = np_utils.to_categorical(y_test)
    num_classes = test_labels.shape[1]

    print(train_images.shape) # (60000, 784)
    print(test_images.shape)  # (10000, 784)

    # Build keras model
    model = Sequential([
        Dense(64, activation='relu', name='Input', input_shape=(784,)),
        Dense(64, activation='relu', name='Hidden1'),
        Dense(64, activation='relu', name='Hidden2'),
        Dense(10, activation='softmax', name='Output'),
    ])

    model_time = process_time()
    print(" ")
    print("Begin modeling...")

    # Compile the model
    model.compile(
        optimizer=keras.optimizers.Adam(),
        loss=keras.losses.categorical_crossentropy,
        metrics=['accuracy'],
    )

    # Train the model.
    model.fit(
        train_images, train_labels,
        validation_data=(test_images, test_labels),
        epochs=10,
        batch_size=200,
        verbose=2
    )
    scores = model.evaluate(test_images, test_labels, verbose=0)
    print("Baseline Error: %.2f%%" % (100-scores[1]*100))

    print(" ")
    print("Model Run time:", run_time(model_time))

    # Predict on the first 5 test images.
    predictions = model.predict(test_images[:5])
    # Print our model's predictions.
    print(" ")
    print("First five values")
    print(np.argmax(predictions, axis=1)) # [7, 2, 1, 0, 4]
    print("Compare the labels")
    # Check our predictions against the ground truths.
    print(test_labels[:5]) # [7, 2, 1, 0, 4]

    print(" ")
    print("Run time:", run_time(begin_time))
    print("...Finished...End of Line")

I then read some of the rules I picked up from the gaming stores to unwind. It is hard to change gears.

Dinner was grilled teriyaki chicken with green beans. I did have to go outside for the grilling–oh my! I served Susie and myself.

I had boiled the chicken before teriyaki sauce and grilling to ensure it was cooked and remove the flame-ups. Often raw chicken with teriyaki sauce is a fire hazard with a burned outside and uncooked in the middle. I avoided that.

I kept some chicken out of the flames and teriyaki and made chicken salad for tomorrow.

I cleaned the kitchen and then poured myself a gin and tonic before writing this. It is the right kind of day for gin and tonic. It is made from Oregon Gin, Canda tonic, and the lime was from Mexico. A perfect liberal drink!

IMG_1301

Today more than four-hundred fifty people in the USA died from the virus, according to reports. The week’s totals are ten percent higher than the previous week.

With all the attacks in Portland and the problems and the terrible losses, I picked The Star Spangle Banner from here in liberal Oregon and Portland Greater Area. This is followed by “American the Beautiful” in the video.

The drink is empty so it is time to stop. Good night!

Day 133: Saturday Free RPG Day

Today was a bit of a busy start. I headed to Rainy-Day Games to get the free swag for the Free Role Playing Game (RPG) Day. They open at 10 in the morning, so I was there at 9:35 and was third in line. I discovered it was not only Free RPG Day but also Warhammer 2000 was releasing a new set today. I saw a version of them being painted yesterday at Guardian games. The staff there was painting why checking in people at the store. That is my kind of store! I still do not play Warhammer 2000. The buy-in cost and time are too much, but it looks so nice…

IMG_1298

(waiting at Rainy-Day Games here in Aloha)

I started up about 8ish and got going with food and then shower and all of that.

I went and waited and then we went in. Only eight people are allowed in the store at a time, with masks, and socially distant no matter how cheap that used RPG stuff is. I picked up two free items and purchased a rule book for Vampire: The Requiem that I do not have. I have never played, nor am I interested in a story-telling game about living in a depressing world of evil, but for $5, I can read about and see if I am missing out. I have read a bit and Vampire: The Requiem is well written and very dark. This book is the original source material from 2004 and is not enough to play the game. The new second edition has a single book now. For $5, I can see what this is about.

I also picked up Root the RPG. A small booklet on how to use all my Root board game with its various extensions and play it as an RPG. I was happy to get this as that was the whole reason for making Free RPG Day today. It is another option for Root.

61739172617__42D9E934-B565-467A-89A6-307F86F8BABF

I also picked up a free adventure for Starfinders, Skitter Home. Imagine if you take Pathfinders, a reworking of Dungeons and Dragon of the super buffing and overpowering 3.5 version, and turn it into a space game. That is what Starfinders is. I hope to get a chance to play some time at the next convention. Corwin and Cory, both in our gaming group, love Starfinder.

IMG_1299

I then left the store, and by 10:03 had my new books and happy. I returned home.

At 11:00AM, I was on a Zoom meeting for the Meet-up with Garret. The Knowledge Mavins have been meeting and using Zoom before it was widely known. Today’s meeting was on Machine Learning and some easy Python coding. Darren did a great job: Recorded Here. Garret has been hosting all sorts of exciting stuff over the last couple of years. I try to show when I can.

Mariah and I had lunch plans. Susie, unknown to me, fell this morning and got herself off the floor. Her wrist is bruised. I popped off for Buffalo Wild Wings, not knowing about this.

The wings place has masks, cleaned tables, and distancing done right, so I am comfortable having lunch there. We always pick outside as few go on the deck, so we are a bit safer.

I then drove to Rune and Board the Hillsboro game store. I met the owner and learned RPG stuff where 20% discounted. He pointed me to his new favorite, Blades in the Dark, and Dungeon Crawl Classics (DCC). The rule book for DCC is two inches thick! He found me the free Quick Start version. I did buy Blades in the Dark as I liked the theme (assassins) and comes from Evil Hat Productions–their stuff has always been excellent. I also have Level 1 magazine, which is full of little Indie RPG games. More on that later day.

So vampires, assassins, space adventures, Root RPG, and DCC is a lot of loot. It was a good day!

I returned home–I was singing along with the Phantom of the Opera in Air Volvo thinking it fit with most of my new materials–and Corwin’s partner Evan was here. The metal grinder was delivered today, you can get tools from Amazon–almost anything–, so Evan and Corwin made some progress in the blacksmithing lab that was once my backyard deck.

I made pastitsio tonight. We finally had ground lamb delivered. So it was time to finally go Greek! I had to shop in Safeway to get a few more items and paper towels that we were out. I know the folks there, and they were happy to see me.

I did all the cooking once I had everything. I made a salad and bought some good bread. Dinner was good and all, yes all, of the pastitsio is gone. The kitchen now looks like a cooking war zone. 

Susie is OK and rode her bike.

Not a bad day.

Reports show more than nine-hundred Americans died today from the virus.

I went with the Rock of Ages for tonight to remember all we have lost.

 

Day 132: Friday and see Portland

Layoffs were the news at Nike today. Not my organization but all over the shoe company with re-organizations. This was all announced at 2 PM after the company entered the summer hours.  I was back online reading all the emails and looking at the very vague diagrams trying to understand the meaning of the organizational changes and a hint of what was philosophy underlying the changes. There are always explanations, but ambiguous words never satisfy. In the end, I was sad and unhappy–the usual for layoffs.

My day started at 6:15ish this morning, making coffee and reading all the emails and getting ready for hours of Zoom meetings. The meetings and emails and text were about real issues and trying to solve real computer problems or me covering some of the histories of why the computer systems work the way they do for new employees. Resolving issues and recalling why things are the way they are made it a happy day for me, and with the day ending at noon, it was a good Friday.

I finished my last meetings and then got in Air Volvo and headed to Portland. My mother, I called her to check in, was concerned that I would be injured or arrest by some crazy Federal person. I told her that I would go with the Portland approach and just strip down and pose for the police if things got complicated. My mother was sure that my plan was flawed, but I explained it had worked a few nights ago for others–how could it fail for me. She rang off, still worried, but reassured that I was not headed to the Federal Court House in Portland.

Instead, I drove over the Burnside and the new Gaming store, Mox Boarding House. Mox opened just a few weeks ago, and I wanted to support my local gaming store and have lunch. They have a bar, and Sydney and Tatyana served me lunch.

IMG_1296

(the bar with Tatyana)

I had the lamb with pasta and a sour beer. It was great.

They stamped my parking, you get 90 minutes of complimentary parking. I parked in the garage they share with the soccer stadium.

I then drove further on Burnside and the bridge to get to Guardian Games and picked up an older book on Lankhmar for the Savage Worlds system. I did not have this one, Savage Seas of Nehwon, so I picked it up. Someday I will play a Lankhmar based role-playing campaign. Some day without a virus…

Next, I drove back, avoiding the Federal Court House and City Hall area, and went to the very local Rainy-day Games here in Aloha and bought the April edition of Wargames Illustrated magazine. I use to buy it when it came out at the bookstore for something to read at lunch when working in the office. I completely forgot about it as I no longer have those habits and all the places I usually buy it are closed. I am shocked that I completely forgot about it and wondered what else I am missing.

Wargames Illustrated is a UK publication that covers miniatures mostly 28mm (used in Dungeons and Dragons) and 15mm used in tabletop gaming. It reviews all the cool miniatures and some games and rules to use miniatures. It also has a good section on books too—all in glossy color to make me want to try again to paint figures that good.

I got home, and Corwin and Susie had scrambled eggs and cold steak leftover from my cooking yesterday. I just had a bagel as I had a large lunch, and breakfast was a bagel and banana.

I got out Brass: Lancashire again. Brass is my newest board game purchase, and I am still trying to learn it. I managed to play a two-player game without that many errors, all minor and fixable. I know I am getting the rules down as I find myself wondering how to play instead of trying to remember the rules or actions. I also had trouble with my choices and how best to do the play. The whole design of Brass is to make you decide and face the results of those choices. Decisions are hard, and the results are to follow the paths from those choices. Do I increase my network, or maybe build a mill, or sell some cotton? Brass: Lancashire plays 2-4 players in just a few hours or less. I think I like it, but it is much harder than most games I play.

While I was moving over to the next epoch in Brass, a friend of mine just bought a car and need a lift. So I headed out and helped out.

I will finish the Brass game after I write this.

Tomorrow is Free RPG Game Day and looks for me in-line to get into Rainy-day Games in the morning.

The USA stock market went down again and is down for the week. I have sold most of my short term holdings. I decided to settle for what I could get than hope for higher.

Reports show another eleven-hundred Americans’ lives with cut short today by the virus.

Today’s hymn to remember all we have lost today is Abide with Me.

 

Day 131: Thursday with Zoom

A sad day for me.

Today started a bit late as it was hard to start. I had problems sleeping last night, and so I was not feeling up to facing the world. The world started anyway, and Nike announced layoffs of all the teachers and people from the day school. Nike will no longer have service at WHQ. One of my favorite things, when I worked on campus at WHQ Nike, was to see the little people marching around the lake and the little carts full of the smaller folks. I cannot believe that day-care and all the kids will now be gone from WHQ. We will never see the little folks again, and I am very sad about that change.

Work went on, and I did many tasks while listening on Zoom calls. Today was a lot of status and planning as we start the next work increment. I was responding to technical items while in the Zoom calls. I try to remember to go on mute and take down the video when I am busy with other tasks.

I had DoorDash deliver Einstein Bagles lox bagels and a dozen more bagels for later. I had another bagel for lunch and for a snack later.

Unrelated to the news about the loss of childcare at Nike, I liquidated much of my remaining holding of options and stock today. I have been selling most of my stock holdings over the last couple of weeks. I feel that the recovering is not happening and we are headed to deeper bad times. People are not working in many industries.

With the money, I plan to pay off the car and other items and hunker-down even a bit more. My 401K is still in the market but even that is making me nervous. I am not quite ready to join the gold bugs and coin hoarders, but I am concerned, and this way, I am reducing my personal exposure to risk for shorter-term assets.

Do have to admit that reducing the money spent on books (even Kindle) and board games may require more strength of will than I have: Mr. Wick. I will try to have a focus.

Dinner was ribeye steaks done on the gas grill with just salt and pepper. I made steamed carrots. I made egg-noodles with butter and a touch of Herb de Provence and salt. As usual, I did not put enough salt on everything, but I have high blood pressure and salt is “white-death” to me so I use it lightly (I use unsalted butter).

Impacting my decision to sell everything today was the US market fall of more than three-hundred fifty points. I felt I should get out while I still can (I still have Virgin Galactic and Ford just for emotional reasons). I will know by the year-end if I was right.

No comment on the protesting as all that is in the international news.

I hope to head to Mox on Friday afternoon, Nike closes at noon on Fridays. I want to see how they are doing after a few weeks of being open. Have to support the local gaming company.

The reports show that more than eleven-hundred Americans’ lives were cut short today by the virus.

I found this choir for today’s song: How Excellent.

Here is the sunset looking from my deck in the back.

IMG_1295

(the comet Neowise is the other direction and is obscured by all the trees)

Day 130: Wednesday Approval Day

We just got home tonight, and after a short rest, I started to write this.

A short story today as most of the day was working.

We previously stopped at the gas station to get gas for Air Volvo, the name of my car. Air Volvo was showing a warning light and counting down until it runs out of gas. It starts at fifty miles and lets you know how many miles you have left. I have filled the car four times now since the emergency.

Before gassing up and making Air Volvo stop warning about having only fifty miles left, we went to the Rockcreek Tavern McMenamin for a beer with a friend. Susie had a plain cheeseburger with bacon on the side, I had a Portland Dip (instead of beef it has turkey), and the same for our friend. We had masks as did most folks. Everything was served correctly, timely, and with a mask.

Before we headed to dinner, I worked until 6PM approving various documents and reviewing designs all afternoon. It is the last day of the current work increment, and I discovered as Technical Architect, I am the approver all of the work. All of which I helped design and agreed too. Thus, it was not challenging to accept it all–it just took all day.

An aside, on one of the calls we talked about NFL and I, thought a picture of the award we got for making all the emergency changes to Nike computer years ago for the NFL contract would be fun. We get just one shoe, and this one was in bright colors and a metal tag.

IMG_1294

(Getting NFL right was critical to Nike. The shoe means a lot to me)

One of my favorite parts of watching an NFL game on TV is when the camera pans, and I see the crowd wearing all Nike t-shirts and jerseys. We made that all work, and it took multiple enhancements and some “pixie dust” I invented. It is a thrill for me when I see the crowds at a game in our bright sportswear.

Returning to our story, lunch was Burger King drive-thru, I love their burgers and a McDonald Happy Meal for Susie.

I started at about 7AM and was busy answering emails and being part of Zoom meetings. Most I had to say something, so I was working much of the morning.

The market was headed up again. I was so busy I did not catch much of the news. It appears that the market is still happy about a vaccine for the virus and some form of stimulus coming from Washington, D.C.

On the protesting, Portland found a new way to be annoying to the Federal troops. Apparently, leafblowers work to send the tear gas canisters back into the Federal police forces. I read that this is genuinely unexpected and frustrating to the Fed cops. I also read a report that Mayor Wheeler is fed-up and has joined the protestors–a unique Portland solution, but not likely to be true**. And, acting Secretary Wolf was quoted that the Federal forces are making “pre-emptive” arrests for protesting–which is a head-scratching comment.

The reports show that more than twelve-hundred Americans perished from the virus today.

With no attempt at irony, I found this song and thought this lockdown version was nice: Pass it On.

**Update: Mayor Wheeler was at the protest to talk to people when he was tear-gassed.