Category Archives: Tensorflow

Phil 7.3.20

Today is a federal holiday, so no rocket science

Huggingface has a pipeline interface now that is pretty abstract. This works:

from transformers import pipeline

translator = pipeline("translation_en_to_fr")
print(translator("Hugging Face is a technology company based in New York and Paris", max_length=40))
  • [{‘translation_text’: ‘Hugging Face est une entreprise technologique basée à New York et à Paris.’}]

Wow: GPT-3 writes code!

DtZ is back up! Too many countries have the disease and the histories had to be cropped to stay under the data cap for the free service

GPT-2 Agents

  • Work on more granular path finding
    • Going to try the hypotenuse of distance to source and line first – nope
    • Trying looking for the distances of each and doing a nested sort
    • I had a problem where I was checking to see whether a point was between the current node and the target node using the original line between the source and target nodes. Except that I was checking on a lone from the current node to the target, and failing the test. Oops! Fixed
    • I went back to the hypotenuse version now that the in_between test isn’t broken and look at that!

granular

    • Added the option for coarse or granular paths
  • Start thinking about topic extraction for a given corpus

#COVID

  • Evaluate Arabic to English translation. Got it working!
    from transformers import MarianTokenizer, MarianMTModel
    from typing import List
    src = 'ar'  # source language
    trg = 'en'  # target language
    sample_text = "لم يسافر أبي إلى الخارج من قبل"
    sample_text2 = "الصحة_السعودية تعلن إصابة أربعيني بفيروس كورونا بالمدينة المنورة حيث صنفت عدواه بحالة أولية مخالطة الإبل مشيرة إلى أن حماية الفرد من(كورونا)تكون باتباع الإرشادات الوقائية والمحافظة على النظافة والتعامل مع #الإبل والمواشي بحرص شديد من خلال ارتداء الكمامة "
    mname = f'Helsinki-NLP/opus-mt-{src}-{trg}'
    
    model = MarianMTModel.from_pretrained(mname)
    tok = MarianTokenizer.from_pretrained(mname)
    batch = tok.prepare_translation_batch(src_texts=[sample_text2])  # don't need tgt_text for inference
    gen = model.generate(**batch)  # for forward pass: model(**batch)
    words: List[str] = tok.batch_decode(gen, skip_special_tokens=True) 
    print(words)
  • It took a few tries to find the right model. The naming here is very haphazard.
  • Asked for a sanity check from the group
    • This:
      الصحة_السعودية تعلن إصابة أربعيني بفيروس كورونا بالمدينة المنورة حيث صنفت عدواه بحالة أولية مخالطة الإبل مشيرة إلى أن حماية الفرد من(كورونا)تكون باتباع الإرشادات الوقائية والمحافظة على النظافة والتعامل مع #الإبل والمواشي بحرص شديد من خلال ارتداء الكمامة
    • Translates to this:
      Saudi health announces a 40-year-old corona virus in the city of Manora, where his enemy was classified as a primary camel conglomerate, indicating that the protection of the individual from Corona would be through preventive guidance, hygiene, and careful handling of the Apple and the cattle by wearing the gag.

       

  • Write script that takes a batch of rows and adds translations until all the rows in the table are complete

Book chat

Phil 6.18.20

Hotel reservations!

Sent a ping to Don about a paper to review

GPT-2 Agents

  • Started on common neighbor algorithm. Definitely a good place for recursion
  • Generating larger file

adjacency

moves

  • If you look at the center of the plot and squint a bit, you can see a bit of the grid:

networkx

  • There is an error: The string ‘, White moves pawn from h3 to g4. White takes black pawn. LCZero v0.24-sv-t60-3010 moves black knight from h5 to g7. White moves pawn from g4 to h5. LCZero v0.24‘ is parsing incorrectly due to the truly bizarre name (The little known Grand Master LCZero v0.24-sv-t60-3010). Need to fix the regex. I think I just need to make it so that there has to be a space in front and a space/period after.

GOES

  • Readthrough of GVSETS paper
  • 2:00 Meeting

Waikato

  • Alex had a really good insight in that groups that are working at coming to consensus use terms to discuss their level of agreement that are independent of the points being argued. That’s could really be important in text analysis.

Phil 6.11.20

Call Simon

GPT-2 Agents

  • Embeddings and plots
  • Got the sequences generated. They look pretty cool too, like codes:
    e2 e4 c7 c5 g1 f3 b8 c6 d2 d4 c5 d4 f3 d4 g7 g6 b1 c3 f8 g7 f1 e2 d7 d6 c1 g5 a7 a6 d1 e2 f6 e8 f2 f3 e8 c7 g5 f4 f7 f5 e4 f5 g6 f5 e2 f3 c7 d5 f3 g4 c8 d7 e2 d2 d8 c7 b2 b3 f5 f4 d4 b3 d7 f5 f1 e1 e7 f5 e1 e6 f5 g4 b3 d4 a8 c8 d4 f5 c6 f5 e6 f6 f5 d4 a1 e1 g4 h5 f3 f4 f8 f6 d2 f6 c8 f8 f6 h4 d4 e6 c2 c3 e6 d4 c3 d4 h5 f3 e1 e7 f8 f7 e7 f7 g7 f7 g1 f2 b7 b5 c4 b5 a6 b5 g2 g4 f7 g6 h2 h3 g8
    e2 e4 c7 c6 d2 d4 d7 d5 b1 d2 g8 f6 f1 d3 d5 e4 d2 e4 b8 d7 g1 f3 e7 e6 d1 e2 f6 e4 d3 e4 d8 c7 e4 b1 d7 f6 c1 g5 f6 g4 h7 h6 g5 h4 c7 d7 e2 e3 g4 e5 h1 g1 e5 c6 f2 f3 f8 e7 e3 e2 g2 g4 f8 d8 f3 e5 d7 d3 e2 d3 d8 d3 g1 d1 a7 a6 c1 b1 d3 d6 b1 a1 e7 f6 a2 a3 c8 e6 f3 e4 b7 b5 b2 b4 f6 g7 b4 a5 b5 a4 e5 c6 a8 b8 d1 f1 a4 a3 c6 e5 a3 a2 h4 e1 a2 a1 f1 a1 b8 a1 d4 d5 e6 c8 d1 b1 g8 f8 a1 b1 f8 e7 b1 c2 e7 d6 e5 d7 g7 d4
    e2 e4 e7 e6 d2 d4 d7 d5 b1 c3 f8 b4 e4 e5 b4 c3 b2 c3 g8 e7 d1 b3 c7 c5 a2 a3 b8 c6 f2 f4 b7 b5 a3 a4 b5 b4 b3 b2 a4 a5 c5 d4 c3 d4 e7 g6 g1 f3 c6 e7 c8 a6 c1 g5 e7 g8 a1 b1 a8 c8 e5 d6 g8 f6 g5 f6 d8 f6 f1 f2 h7 h6 b2 b5 f6 d6 f3 h4 d6 e7 h4 g6 a6 g2 g6 e7 f8 e8 e7 f5 g2 f3 g1 g2 c8 c2 b1 c1 c2 c8 a5 a6 c8 a8 h2 h3 f3 e4 b5 b3 f7 f6 b3 b2 f6 f5 f5 d6 e6 e5 b2 a1 e8 a8 f2 f5 f5 e4 f5 f7 a8 b8 c1 f1 b8 b5 a1 a2 a8 a7
    e3 d2 d4 g8 f6 c2 c4 e7 e6 b1 c3 f8 b4 e2 e3 c1 d2 d7 d5 c4 d5 f6 d5 f2 f3 b8 c6 g1 f3 f7 f5 g2 g4 f5 g4 d1 e2 d5 f4 d2 f4 e6 f5 e2 e5 b4 c3 e5 c3 d8 d3 e1 e2 d3 e2 e2 e2 f5 f4 e2 e1 f4 f3 e1 f2 a8 d8 f2 f1 c8 e6 f4 e3 f8 f7 f3 h4 e6 d5 f1 g2 f7 f3 g2 f1 f3 h3 f1 e1 d5 e4 e1 f2 h3 h4 g4 h5 h4 h5 f2 f3 h5 f5 f3 g2 f5 h5 e3 g5 h5 h3 g5 e3 h3 h4 e3 g5 e4 g2 g2 g3 g2 d5 g3 h3 d5 e6 g5 f6 g8 h7
    e2 e4 e7 e5 g1 f3 b8 c6 b1 c3 g8 f6 f1 b5 d7 d6 d2 d3 a7 a6 f8 e7 b5 a4 b7 b5 a4 b3 h2 h3 c8 b7 a2 a4 b5 b4 a4 b5 c6 b8 c1 g5 f6 e8 f3 e5 e8 d6 g5 f4 d8 e7 f4 d6 e7 d6 e5 f3 d6 e7 c3 a4 c7 c6 a4 c5 c6 c5 d3 d4 e7 e5 d4 c5 b7 c8 a1 c1 b8 d7 f3 e5 f7 f6 e4 f5 d7 f6 c1 c6 e5 e4 g1 h1 f6 h5 f1 e1 h5 g3 e5 d7 e4 h4 c6 c4 h4 g3 d1 g4 g3 h3 h1 g1 h3 h1 g1 h2 h1 h5 g4 f5 c8 b7 c4 c5 h5 e2 e1 d1 e7 f6 b2 b3 f6 e5 c5 c8 a8 c8

     

  • Drawing the embeddings. Fun, but not really useful. And this is kind of my point about embeddings like W2V that don’t take into account the trajectory of the sentence the word is part of. We know that the structure of the board is represented in the text. We need a more sophisticated embedding to to extract it

square_embeddings

  • Something that might make sense is to see how these points cluster as well
  • I think I might try plotting individual columns later, but first I’m going to try building some from/to networks by piece

GOES

  • Try downloading yaw flip
  • Was able to connect to the server, though now I don’t need a port number?
  • Specifying the queries. Fixed a few mnemonics.
  • Had to try a few times, but I got it!

influx_copy

  • Not sure what to do next. Update GVSETS paper?
  • 2:00 CASSIE meeting – learned a lot of things
  • I got promoted!
  • Implemented a perplexity measure. Looking at this as a way of understanding mode collapse, and maybe conspiracy theories?
  • Done for the day

Phil 6.9.20

I’ve been thinking about writing a paper about how the development of conspiracy theories resembles the mode collapse condition in GAN creation. There is some recent research in the GAN community on developing tools for detecting mode collapse (Jai & Zhao, 2019) that I think could be extended to identifying conspiracy theories and the processes that create them. Maybe for ICTAI 2020?

Studying Programming in the Neuroage: Just a Crazy Idea?

  • What we were proposing to do was simple yet ambitious. Using functional magnetic resonance imaging, we might better understand what goes on in the minds of programmers as they read and understand code.
  • The results indicated that a specific network of brain areas in the left hemisphere was used by participants to understand code, including areas related to working memory, divided attention, and reading comprehension. Surprisingly, we did not observe cognitive processes related to mathematical and logical reasoning, which would be consistent with the perspective that programming is a formal, logical, and mathematical process.

GPT-2

  • Start storing data!

db

  • Try new probes – done!
    probe_list = ['The game begins as ', 'In move 10', 'In move 20', 'In move 30', 'In move 40', 'White takes black ', 'Black takes white ', 'Check. ']
  • Added the raw text to the table_moves instead of comments. Here’s the new and improved:

db

  • Start thinking about metrics, like adjacency matrices by piece?
  • Build gensim embeddings of games and pieces
  • Build agent network graphs by piece type and from/to

GOES

  • Nothing back from Vadim, so I think I’ll continue on my Wasserstein Loss algorithm
  • Hey! The DevLab Influx is reachable again!

influx

  • Going to take advantage of this and find more mnemonics, Done!
  • Now I need to figure out a good way to pull down the data and load it on my system
  • Working on DevLabInfluxQuery class that extends InfluxQuery. Done, but fails with one of these exceptions:
    • Unable to parse CSV response. FluxTable definition was not found.
    • Connection aborted.’, TimeoutError(10060, ‘A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond’, None, 10060, None)
    • Tried upgrading my influxdb-client (pip install –upgrade influx-client) from 1.5 to 1.9. Hopefully i didn’t break too much. Didn’t fix it with that, but I got the port number for Boris, which fixed things

devlabInflux

ML seminar

  • Discussed options for visualizing relationships between nodes. Starting with just straightforward plotting of connected nodes. Also, plotting by piece. Another option is to use the gensim library to do a word2vec embedding and visualize it. I think I’ll start there because I’m curious.
  • To improve the embedding, it might be useful to generate entire games and parse them.

 

Phil 6.8.20

Not at all happy with this COVID weight gain. My preferred stress management tool is exercise, but I’m at a minimum of 20 miles/day. Usually about 100 miles+ on weekends.

Starting to think about writing something on the ethics of mode collapse

D20

Florida

GPT-2 Agents

  • Back to pulling move and piece information out of generated text – done
  • Added heuristic for move number
  • Created dicts for db data. Add writes tomorrow!

GOES

  • Adding read tests – done! Had to screw around with utc conversions for a while
    • Writes are roughly 1/2 sec per 1,000
    • Reads are about 2/100 sec per 1,000
  • Tried to log in and get on the devlab influx system – nope:

bad gateway

  • Trying to figure out what makes sense to do next. Ping Vadim? Done

Phil 6.5.20

GPT-2 Agents

  • Started a google doc for the GPT-2 Chess agents that will be grist for the paper(s)
  • Create probes for each piece, like:
    • white moves pawn from e2 to
    • black moves pawn from e7 to
    • A slightly more sophisticated parser will need to work with “The game begins
  • I can take the results of multiple probes and store them in the table_moves, then run statistics by color, piece, etc
  • Then see if it’s possible to connect one piece to another piece using a “from/to chain” across multiple pieces. There will probably be some sort of distribution where the median(?) value should be a set of adjacent squares.
  • The connections can be tested by building adjacency matrices by piece and by move number range
  • Started ChessMovesToDb. Might as well work on the tricky parse of  “The game begins “. Making progress. My initial thought on how to parse moves doesn’t handle weird openings like “4.e3, Gligoric system with 7…dc” Need to strip to the the first occurance of “move”, I think:
    white uses the Nimzo-Indian opening. and black countering with 4.e3, Gligoric system with 7...dc. White moves pawn from d2 to d4. Black moves knight from g8 to f

GOES

  • More timing tests
    • Add explicit time to the write
    • This should also be the basis of the system that will pull data from the DevLab Influx
  • Continue search for important mnemonics during yaw flip – nope, still can’t log into DevLab influx
  • Working on setting up arbitrary times spans and a new bucket for tests. Writing data works. Now I need to extend the number of series, tags, etc influxAll the writes are working. I’ll do the reads Monday. Everything looks pretty consistent, though.

timing

Phil 6.4.20

GPT-2 Agents

  • Thinking about how to parse the data to build maps.
    • Clearly, there are black and white agents (the players). Option 1 would be to simply collect the from-to points at the player level
    • One step down would be the piece family, pawns, rooks, bishops. The king and queen would be single instances
    • The most granular would be to track the individual pieces.
    • The issue I’m struggling with is when pieces pass over squares rather than through them. There is no explicit d3 when white moves the pawn from d2 to d4. Trying to think of the best way to uncover the latent information.
    • I think a good way to procrastinate about this problem is to parse the games into a database of moves. The format is always “<player/color> moves <(color)piece> from <start> to <end>. There is additional information as well (game, players, move number), but that could be added later.
    • Done
    • table_moves
    • Sent a note to Thomas Wolf at Huggingface
    • I know what I’m going to do!
      • Create probes for each piece, like:
        • white moves pawn from e2 to
        • black moves pawn from e7 to
        • A slightly more sophisticated parser will need to work with “The game begins
      • I can take the results of multiple probes and store them in the table_moves, then run statistics by color, piece, etc
      • Then see if it’s possible to connect one piece to another piece using a “from/to chain” across multiple pieces. There will probably be some sort of distribution where the median(?) value should be a set of adjacent squares.
      • The connections can be tested by building adjacency matrices by piece and by move number range

GOES

  • Hey! The VPN is much more responsive today! Logged into Influx
  • Getting the right time for the query from here
    • start: 2020-04-06 15:30:00.000
    • end: 2020-04-06 18:00:00.000
    • Need to get the right mnemonics. Pinged Bruce
  • Starting some timing tests on my local influx copy
  • The VPN has stopped again
  • 2:00 NSOF Meeting – Nice demo by Jason
  • 3:30 AIMS IRAD
    • Status. John is going part time
    • Railed against the poor VPN access to the DevLab

ML Brownbag – Aaron did a nice job

Phil 6.3.20

MarthaRaddatz

“When the students poured into Tiananmen Square, the Chinese government almost blew it. Then they were vicious, they were horrible, but they put it down with strength. That shows you the power of strength”Donald Trump, 1990

GPT-2 Agents

  • Finished finetuning the model yesterday, and tried running it with the following seeds:
    text_list = ['The game begins as ',
                 'White moves ',
                 'Black moves ',
                 'In move 1, ',
                 'In move 40, ']
  • The results are pretty incredible:

generated_chess

  • Opening moves (“The game begins as”, “In move 1”) make sense. White always moves first. Pieces move in reasonable, permissible ways (e.g d3 to d4)
  • The model knows how to take pieces correctly. The red lines connect moves by White and the counter-move by black, then the taking of the piece.
  • Moves that occur later in the game are also sensible. (“In move 40”, “White moves”. “Black moves”)
  • Names occur very infrequently. And Loek is probably the most frequent name, since his entire career is in a pgn file
  • I think the next steps are:
    • Create marker text for SBoW analysis, like  “In move 1, White moves pawn from d2 to d4. Black moves knight from g8 to f6.“, and “In move 40, White moves rook from d1 to d7. Black moves pawn from e5 to e4.” so that I can use the antibubble analytics
    • Create a parser that looks for the movements of particular pieces (white pawns, black knights, etc) and see if I can build a map from that using the agent tools. Pawns and kings may provide the projection, while other pieces move over that
  • Good results today!!!

GOES

  • Create Github repo for brownbag – done
  • Status report – done
  • Ping Biruh about accessing the on-site InfluxDB – done
  • Ping Boris and Bruce for mnemonics and yaw flip times
  • 2:00 meeting
  • Build a set of stress tests for influx.
    • samples 300 x 7,000 floating point
    • tags: benchmark tags 2, 4, 8, 16, 32, etc
    • Vadim for Cassie DB questions

#COVID

  • Meeting cancelled

Phil 5.28.20

GPT-2 Agents

  • Back to bug hunting today’s job is to figure out why this:
    1. Nf3 Nf6 2. g3 c5 3. Bg2 Nc6 4. O-O e5 5. e4 Nxe4 6. Re1 Nf6 7. Nxe5 Be7 8. c4
    O-O 9. Nc3 Nxe5 10. Rxe5 d6 11. Re1 Be6 12. Bxb7 Rb8 13. Bg2 Bxc4 14. d4 Be6 15.
    b3 Rb4 16. dxc5 dxc5 17. Qxd8 Rxd8 18. Ba3 Rbb8 19. Na4 Rdc8 20. Rac1 Nd7 21.
    Bd5 Bxd5 22. Rxe7 Bc6 23. Nxc5 Nxc5 24. Rxc5 a6 25. f4 h6 26. Kf2 Bb5 27. Ke3
    Rd8 28. Rcc7 Rd3+ 29. Ke4 Rd2 30. Rxf7 Re8+ 31. Kf5 Bd3+ 32. Kg4 Rxh2 33. Rxg7+
    Kh8 34. Bd6 Rf2 35. Bc5 Rd2 36. Bb4 Rc2 37. Rxc2 Kxg7 38. Rc7+ Kg6 39. Rc6+ Kf7
    40. Rxh6 Re2 41. Rd6 Re3 42. Kh4 Be2 43. g4 Rf3 44. Rd4 Rf2 45. Kg5 1-0
  • breaks the system.
  • So I never added logic to see if the path was clear for a move. The game has a move where white rook moves from e1 to e5 and then back. For the move back, the system looks for the closest rook, which is actually at a1, as the search algorithm works. But that way is actually blocked by the white bishop and white queen. It should take the clear path and discard blocked paths. I think this fix is pretty straightforward

chess

  • Wrote the test, but I’m not sure if it’s right. We’ll test tomorrow:
        def check_if_clear(self, loc:Tuple, candidate:Tuple, piece:PIECES) -> bool:
            if piece == PIECES.WHITE_PAWN or piece == PIECES.BLACK_PAWN:
                return True
            if piece == PIECES.WHITE_KNIGHT or piece == PIECES.BLACK_KNIGHT:
                return True
            if piece == PIECES.WHITE_KING or piece == PIECES.BLACK_KING:
                return True
            
            c_col_i = self.char_index.index(candidate[0])
            c_row_i = self.num_index.index(candidate[1])
            l_col_i = self.char_index.index(loc[0])
            l_row_i = self.num_index.index(loc[1])
            col_dist = l_col_i - c_col_i
            row_dist = l_row_i - c_row_i
            dist = max(abs(col_dist), abs(row_dist))
            col_vec = 0
            row_vec = 0
            if col_dist != 0:
                col_vec = col_dist/dist
            if row_dist != 0:
                row_vec = row_dist/dist
    
            col_i = l_col_i
            row_i = l_row_i
            for i in range(dist):
                num = self.num_index[row_i]
                char = self.char_index[col_i]
                pos = (char, num)
                p = self.get_piece_at(pos)
                if p != PIECES.NONE:
                    return False
                col_i += col_vec
                row_i += row_vec
    
            return True

     

GOES

  • More paper writing
    • Finished the first pass of section 2, which describes the whole model.

Phil 5.27.20

Drop off the truck today!

Agents and expensive information

  • Antonio sent a note asking if I’d be interested in contributing to a chapter. Sent him this response:
    • There is something that I’d like to explore that might fit. It’s the idea that in most environments, agents (animal, human, machine, etc.) are incentivized to cheat. I think this is because information is expensive to produce, but essentially free to copy. The problem is that if all the agents cheat, then the system will collapse because the agents become decoupled from reality (what I call a stampede). So the system as a whole is incentivized to somehow restrict cheating.
    • I think this could be very interesting to work through, but I don’t have a model (or even an approach really) developed that would describe it. I think that this might be related to game theory, though I haven’t found much in the literature.

GPT-2 Agents

  • Working on building a text corpora. Going to add a search for “Opening” and “Variation” which I’ll try before using the DB version – done
  • Having some problem that starts after a few games. Found the culprit game. Will work on tomorrow. It might be tied to a linefeed?

GOES

  • Working on the GVSETS paper and slide deck

Phil 5.26.20

Had a good, cathartic ride yesterday:

GPT-2 Agents

  • I’ve been working on the PGNtoEnglish class and was having an odd bug where occasionally a piece would pull a piece from the other side of the board. Since it was intermittent, it required many print statements and searching through the logs for “black knight”

blac knight

  • My problem was in forgetting how Python indexes into arrays. Here’s the code in question:

python

  • When I first wrote this, I had to deal with a lot of potential coordinates that were off the board, with indexes like (-2, -1), or (10, 8) for an 8×8 board. I thought to handle this with a try/except on IndexError (the bottom highlight). In other languages this would have worked, but Python allows negative indexes. Ooops! Adding the test for either index being negative (the top highlight) fixed that bug

D20

  • Ping Zach – done

GOES

  • Write up code review thoughts for Erik -done
  • Add n_critic to base class, along with adjustable false flag value
    • First, making sure that everything still works. Seems to.
    • Here’s the best I can do today, using the OneDGAN2a class with an RMSProp(lr=0.0005)

epochsNoise_trainedacc_loss

  • Assemble all the bits for an example
    • Verified that the InfluxTestTrainBase still works, and it’s using the InfluxDB values
    • Assemble all the bits for an example
      • Created a NoiseGAN2 with the same amount of points as the InfluxTestTrainBase model – done. Looks real good on the noise, too:

epochsNoise_trainedacc_loss

  • How to trim the columns on a 2D Numpy array:
    results = self.ifq.run_query(self.bucket, begin, end, filter_str)
    results = self.ifq.to_nd_array(results)
    results = np.delete(results, slice(clamp, None), 1)
    predict_table = model.predict(results)
  • Here’s all the parts nailed together:
  • Start the paper and the deck

ML Group

  • Need to create a walkthrough of coding practices for next week. I think I’ll use the trajectory of the GAN coding as the basis

 

Phil 5.21.20

GPT-2 Agents

  • Added Queenside castling
  • Found an ECO opening file here! Now I really want to parse it into a json file and use it
  • Started the to_narrative() method. Here’s the first result!
    In 1987, Fred Van der Vliet played Loek Van Wely. Fred Van der Vliet was the higer-ranked player, with an Elo rating of 2330. Loek Van Wely was unrated. 
    The game began with ECO opening E69: 
    In move 1, Fred Van der Vliet moves white pawn from d2 to d4. Black moves knight from g8 to f6.
    this is a comment
    In move 2, White moves pawn from c2 to c4. Black moves pawn from g7 to g6.
    In move 3, Fred Van der Vliet moves white pawn from g2 to g3. Loek Van Wely moves black bishop from f8 to g7.
    In move 4, Fred Van der Vliet moves white bishop from f1 to g2. Loek Van Wely kingside castles.
    In move 5, White moves knight from g1 to f3. Black moves pawn from c7 to c6.
    In move 6, Fred Van der Vliet kingside castles. Loek Van Wely moves black pawn from d7 to d6.
    In move 7, White moves knight from b1 to c3. Black moves knight from b8 to d7.
    In move 8, White moves pawn from e2 to e4. Loek Van Wely moves black pawn from e7 to e5.
    In move 9, White moves pawn from h2 to h3. Loek Van Wely moves black rook from f8 to e8.
    In move 10, White moves rook from f1 to e1. Loek Van Wely moves black queen from d8 to b6.
    In move 11, White moves pawn from d4 to d5. Black moves knight from d7 to c5.
    In move 12, White moves rook from a1 to b1. Black moves pawn from a7 to a5.
    In move 13, White moves bishop from c1 to e3. Black moves queen from b6 to c7.
    In move 14, Fred Van der Vliet moves white knight from f3 to d2. Loek Van Wely moves black knight from f6 to h5.
    In move 15, White moves queen from d1 to e2. Black moves pawn from h7 to h6.
    In move 16, White moves pawn from d5 to c6. White takes black pawn. Black moves queen from c7 to c6. Black takes white pawn.
    In move 17, White moves knight from c3 to d5. Black moves bishop from c8 to e6.
    In move 18, White moves rook from e1 to c1. Black moves king from g8 to h7.
    In move 19, White moves pawn from b2 to b3. Black moves rook from e8 to b8.
    In move 20, White moves pawn from a2 to a3. Loek Van Wely moves black pawn from b7 to b6.
    In move 21, White moves king from g1 to h2. Black moves queen from c6 to c8.
    In move 22, Fred Van der Vliet moves white pawn from f2 to f4. Black moves pawn from e5 to f4. Black takes white pawn.
    In move 23, Fred Van der Vliet moves white pawn from g3 to f4. White takes black pawn. Black moves rook from a8 to a7.
    In move 24, Fred Van der Vliet moves white knight from d5 to c3. Black moves queen from c8 to d8.
    In move 25, White moves knight from c3 to b5. Black moves rook from a7 to d7.
    In move 26, Fred Van der Vliet moves white pawn from b3 to b4. Black moves pawn from a5 to b4. Black takes white pawn.
    In move 27, White moves pawn from a3 to b4. White takes black pawn. Black moves knight from c5 to a6.
    In move 28, White moves knight from d2 to f3. Loek Van Wely moves black queen from d8 to f6.
    In move 29, White moves queen from e2 to d2. Black moves rook from b8 to c8.
    In move 30, White moves knight from b5 to d6. White takes black pawn. Black moves bishop from e6 to c4. Black takes white pawn.
    In move 31, White moves pawn from e4 to e5. Loek Van Wely moves black queen from f6 to d8.
    In move 32, White moves pawn from b4 to b5. Loek Van Wely moves black knight from a6 to b8.
    In move 33, White moves queen from d2 to b4. Black moves rook from d7 to d6. Black takes white knight.
    In move 34, White moves pawn from e5 to d6. White takes black rook. Black moves bishop from c4 to d3.
    In move 35, White moves rook from c1 to c8. White takes black rook. Black moves queen from d8 to c8. Black takes white rook.
    In move 36, White moves rook from b1 to d1. Black moves bishop from d3 to e2.
    In move 37, White moves rook from d1 to c1. Black moves queen from c8 to e8.
    In move 38, Fred Van der Vliet moves white bishop from e3 to b6. White takes black pawn. Black moves bishop from e2 to f3. Black takes white knight.
    In move 39, White moves bishop from g2 to f3. White takes black bishop. Loek Van Wely moves black knight from h5 to f4. Black takes white pawn.
    In move 40, Fred Van der Vliet moves white rook from c1 to e1. Loek Van Wely moves black bishop from g7 to e5.
    In move 41, White moves rook from e1 to e5. White takes black bishop. Loek Van Wely moves black queen from e8 to e5. Black takes white rook.
    In move 42, White moves queen from b4 to d4. Black moves queen from e5 to b5. Black takes white pawn.
    In move 43, White moves queen from d4 to f4. White takes black knight. Black moves queen from b5 to b6. Black takes white bishop.
    In move 44, Fred Van der Vliet moves white queen from f4 to f7. White takes black pawn. Check. Black moves king from h7 to h8.
    In move 45, White moves queen from f7 to f6. Check. Black moves king from h8 to h7.
    In move 46, White moves bishop from f3 to e4. Black moves queen from b6 to a7.
    In move 47, Fred Van der Vliet wins! Loek Van Wely resigns.
    

GOES

  • Adding better plotting of intermediate values
  • Tweaking the margins, which is not adjusted by the plt.margins() method. It’s actually plt.subplots_adjust(). That took entirely too long to find.
  • Got the plot working, and it is super cool:

epochs

Tried a lower latent dimension (8) and fewer neurons in the generator (32). Not really any different. It does take longer to stabilize though.

epochs

  • Upping the strides on the discriminator to 4. Definitely less mode collapse

epochsNoise_trainedacc_loss

  • Trying a stride of 8. That seems even better, though there is this funky artifact on the right. Going to try it with 10,000 epochs:

Noise_trained

  • Nope, no better. Sticking with the stride of 4. And 5,000 epochs seems to be enough to settle. This really looks a lot like the previous stride=4 run above:

epochsNoise_trainedacc_loss

  • Ok, back to Advanced Deep Learning with Keras and GANS
  • The last part of chapter 4 covered conditional GANS, or CGANS. I think that could be very nice to associate a particular type of noise with the state on a sim. For example, daylight vs. eclipse. It looks pretty straightforward, just the concatenation of a state to the input and discriminator vectors:

CGAN

Phil 5.20.20

Graduation today starting at 10:00!

its_official

D20

  • Looks like ASRC actually wanted us to build a completely different marketing app that would be done by 3 people in 3-4 Fridays. So no sponsorship there

GPT2 Agents

  • Adding promotion – done. I have to say that I’m pretty pleased with how the parser handles it. We go from:
    62. a8=Q+ Kg1 63. Qa7 Kg2

    To:

    [62] expanded: 
    	white: F Caruana moves white pawn from a7 to a8. White pawn is promoted to white queen. Check.
    	black: Ding Liren moves black king from g2 to g1.
    
    [63] expanded: 
    	white: F Caruana moves white queen from a8 to a7.
    	black: Ding Liren moves black king from g1 to g2.

     

  • Had a bit of trouble figuring out how to deal with the end of a file with a potentially incomplete game.
  • Everything works!
  • Now I need to write games out to files, do something with the introductions, etc.
  • Also add some variability in the language later
  • Also need to handle queenside castling (O-O-O)

GOES

  • See how the 20,000 epoch run went, and start on Wasserstein Loss
  • The 20,000 epoch really wasn’t any better. rerunning the 10k and saving the model
  • The 10k version seems to be wider and fits better in the bounds. Looking at the two charts, it looks like following the loss/accuracy of the fake data make be best in this case:
  • Reading the GAN chapter in Advanced Deep Learning with Keras (github)
    • Adding a plot of plots to show the appearance of the generator over the epochs. It should help in understanding the evolution of the generator
    • Bless StackOverflow
      side = 4
      fig = plt.figure(1)
      axs = fig.subplots(side, side)
      fig.set_figheight(15)
      fig.set_figwidth(15)
      for i in range(side*side):
          X = gen_data()
          plot_grid(axs, X.T, i, side=side)
      
      fig = plt.figure(2)
      plt.plot([1,2,3,4,3,2,1,2,3], label = "GREEN", color="green")
      plt.plot([1, 2, 3, 4, 5, 6, 7, 8, 9], label = "RED", color="red")
      plt.legend(loc="upper left")
      plt.show()
  • 2:00 Meeting
    • Write up a code walkthrough proposal and send to Erik
    • set up 10:00 meeting with Vadim for tomorrow
  • 3:00 Log file meeting (T & Isaac)
    • Demo’d LMN and RB

#COVID

  • Good discussion about data and paper writing
  • Tried to see if the annotated twitter data is in the DB. Some is, some is not
  • Tried to get the transformers translate example running again, including downloading the files explicitly. Still didn’t work. Submitted a ticket

Phil 5.19.20

Groceries today. In the Before Time, this meant swinging by the store for fresh fruit and veggies while picking up something interesting for dinner that night. Now it means going to two stores (because shortages) standing in separated lines and getting two weeks of food. Very not fun

A Comprehensive guide to Fine-tuning Deep Learning Models in Keras (Part I)

Visualizing A Neural Machine Translation Model (Mechanics of Seq2seq Models With Attention)

The Illustrated Transformer

Collective Intelligence 2020 explores the impact of technology and big data on the ways in which people come together to communicate, combine knowledge and get work done. (Thursday June 18)

Attention

Attention seq2seq example

#COVID

  • Tried to get the HuggingFace translator (colab here) to download and run, but I got this error: ‘Helsinki-NLP/opus-mt-en-ROMANCE’ ‘Unable to load vocabulary from file. Please check that the provided vocabulary is accessible and not corrupted‘ I’m going to try downloading the model and vocab into a folder within the project to see if something’s missing using these calls:
    # to put the model in a named directory, load the model and tokenizer and then save (as per https://huggingface.co/transformers/quickstart.html):
    tokenizer.save('pretrained/opus-mt-en-ROMANCE')
    model.save('pretrained/opus-mt-en-ROMANCE')

GPT-2 Agents

  • Read in multiple games
    • Handled unconventional names
    • Handling moves split across lines – done
    • Need to handle promotion (a8=Q+), with piece change and added commentary. This is going to be tricky because the ‘Q’ is detected as a piece even though it appears after  the location. Very special case.
      • Rule: A pawn promotion move has =Q =N =R or =B appended to that.
  • Create a short intro
  • Save to txt file

GOES

  • Read the GAN chapter of Generative Deep Learning last night, so now I have a better understanding of Oscillating Loss, Mode Collapse, Wasserstein Loss, the Lipschitz Constraint, and Gradient Penalty Loss. I think I also understand how to set up the callbacks to implement
  • Since the MLP probably wasn’t the problem, go back to using that for the generator and focus on improving the discriminator.
  • That made a big difference!

acc_lossNoise_untrainedNoise_trained

  • The trained version is a pretty good example of mode collapse. I think we can work on improving the discriminator 🙂
  • This approach is already better at finding the amplitude in the noise samples from last week!

Noise_trained

  • Ok, going back to the sin waves to work on mode collapse. I’m going to have lower-amplitude sin waves as well
  • That seems like a good place to start
  • Conv1D(filters=self.vector_size, kernel_size=4, strides=1, activation=’relu’, batch_input_shape=(self.num_samples, self.vector_size, 1))
  • Conv1D(filters=self.vector_size, kernel_size=6, strides=2, activation=’relu’, batch_input_shape=(self.num_samples, self.vector_size, 1)):
  • Conv1D(filters=self.vector_size, kernel_size=8, strides=2, activation=’relu’, batch_input_shape=(self.num_samples, self.vector_size, 1))
  • The input vector size here is only 20 dimensions. So this means that the kernel size is 80% of the vector! Conv1D(filters=self.vector_size, kernel_size=16, strides=2, activation=’relu’, batch_input_shape=(self.num_samples, self.vector_size, 1))
  • Upped the vector size from 20 to 32
  • Tried using MaxPool1D but had weird reshape errors. Doing one more pass with two layers before starting to play with Wasserstein Loss, which i think is a better way to go. First though, let’s try longer trainings.
  • 10,000 epochs:
  • 20,000 epochs:

Phil 5.18.20

Call RV repair – done!

D20

  • Aaron started to poke around in his code again and has some thoughts about how to get the sensitivity we need. I realize that the display that we’re working out will be a good dashboard for seeing second waves. We had a good chat on this and the advantage of using multiple sampling windows, possibly of 7, 14, 30 and all days to get a sense of where things are going.
  • Georgia seems to be heading back up?

Georgia

#COVID

  • Public Health and Online Misinformation: Challenges and Recommendations
    • The internet has become a popular resource to learn about health and to investigate one’s own health condition. However, given the large amount of inaccurate information online, people can easily become misinformed. Individuals have always obtained information from outside the formal health care system, so how has the internet changed people’s engagement with health information? This review explores how individuals interact with health misinformation online, whether it be through search, user-generated content, or mobile apps. We discuss whether personal access to information is helping or hindering health outcomes and how the perceived trustworthiness of the institutions communicating health has changed over time. To conclude, we propose several constructive strategies for improving the online information ecosystem. Misinformation concerning health has particularly severe consequences with regard to people’s quality of life and even their risk of mortality; therefore, understanding it within today’s modern context is an extremely important task.

GPT-2 Agents

  • Finish up PGNtoEnglish?
  • Oops, had the black queen in the wrong place
  • Got it working for one game. Need to try out a bunch next!
    Moves:
    [1] expanded: 
    	white:  Fred Van der Vliet moves white pawn from d2 to d4.
    	black:  Loek Van Wely moves black knight from g8 to f6.
    	this is a comment
    
    [2] expanded: 
    	white:  Fred Van der Vliet moves white pawn from c2 to c4.
    	black:  Loek Van Wely moves black pawn from g7 to g6.
    
    [3] expanded: 
    	white:  Fred Van der Vliet moves white pawn from g2 to g3.
    	black:  Loek Van Wely moves black bishop from f8 to g7.
    
    [4] expanded: 
    	white:  Fred Van der Vliet moves white bishop from f1 to g2.
    	black:  Loek Van Wely kingside castles.
    
    [5] expanded: 
    	white:  Fred Van der Vliet moves white knight from g1 to f3.
    	black:  Loek Van Wely moves black pawn from c7 to c6.
    
    [6] expanded: 
    	white:  Fred Van der Vliet kingside castles.
    	black:  Loek Van Wely moves black pawn from d7 to d6.
    
    [7] expanded: 
    	white:  Fred Van der Vliet moves white knight from b1 to c3.
    	black:  Loek Van Wely moves black knight from b8 to d7.
    
    [8] expanded: 
    	white:  Fred Van der Vliet moves white pawn from e2 to e4.
    	black:  Loek Van Wely moves black pawn from e7 to e5.
    
    [9] expanded: 
    	white:  Fred Van der Vliet moves white pawn from h2 to h3.
    	black:  Loek Van Wely moves black rook from f8 to e8.
    
    [10] expanded: 
    	white:  Fred Van der Vliet moves white rook from f1 to e1.
    	black:  Loek Van Wely moves black queen from d8 to b6.
    
    [11] expanded: 
    	white:  Fred Van der Vliet moves white pawn from d4 to d5.
    	black:  Loek Van Wely moves black knight from d7 to c5.
    
    [12] expanded: 
    	white:  Fred Van der Vliet moves white rook from a1 to b1.
    	black:  Loek Van Wely moves black pawn from a7 to a5.
    
    [13] expanded: 
    	white:  Fred Van der Vliet moves white bishop from c1 to e3.
    	black:  Loek Van Wely moves black queen from b6 to c7.
    
    [14] expanded: 
    	white:  Fred Van der Vliet moves white knight from f3 to d2.
    	black:  Loek Van Wely moves black knight from f6 to h5.
    
    [15] expanded: 
    	white:  Fred Van der Vliet moves white queen from d1 to e2.
    	black:  Loek Van Wely moves black pawn from h7 to h6.
    
    [16] expanded: 
    	white:  Fred Van der Vliet moves white pawn from d5 to c6. White takes black pawn.
    	black:  Loek Van Wely moves black queen from c7 to c6. Black takes white pawn.
    
    [17] expanded: 
    	white:  Fred Van der Vliet moves white knight from c3 to d5.
    	black:  Loek Van Wely moves black bishop from c8 to e6.
    
    [18] expanded: 
    	white:  Fred Van der Vliet moves white rook from e1 to c1.
    	black:  Loek Van Wely moves black king from g8 to h7.
    
    [19] expanded: 
    	white:  Fred Van der Vliet moves white pawn from b2 to b3.
    	black:  Loek Van Wely moves black rook from e8 to b8.
    
    [20] expanded: 
    	white:  Fred Van der Vliet moves white pawn from a2 to a3.
    	black:  Loek Van Wely moves black pawn from b7 to b6.
    
    [21] expanded: 
    	white:  Fred Van der Vliet moves white king from g1 to h2.
    	black:  Loek Van Wely moves black queen from c6 to c8.
    
    [22] expanded: 
    	white:  Fred Van der Vliet moves white pawn from f2 to f4.
    	black:  Loek Van Wely moves black pawn from e5 to f4. Black takes white pawn.
    
    [23] expanded: 
    	white:  Fred Van der Vliet moves white pawn from g3 to f4. White takes black pawn.
    	black:  Loek Van Wely moves black rook from a8 to a7.
    
    [24] expanded: 
    	white:  Fred Van der Vliet moves white knight from d5 to c3.
    	black:  Loek Van Wely moves black queen from c8 to d8.
    
    [25] expanded: 
    	white:  Fred Van der Vliet moves white knight from c3 to b5.
    	black:  Loek Van Wely moves black rook from a7 to d7.
    
    [26] expanded: 
    	white:  Fred Van der Vliet moves white pawn from b3 to b4.
    	black:  Loek Van Wely moves black pawn from a5 to b4. Black takes white pawn.
    
    [27] expanded: 
    	white:  Fred Van der Vliet moves white pawn from a3 to b4. White takes black pawn.
    	black:  Loek Van Wely moves black knight from c5 to a6.
    
    [28] expanded: 
    	white:  Fred Van der Vliet moves white knight from d2 to f3.
    	black:  Loek Van Wely moves black queen from d8 to f6.
    
    [29] expanded: 
    	white:  Fred Van der Vliet moves white queen from e2 to d2.
    	black:  Loek Van Wely moves black rook from b8 to c8.
    
    [30] expanded: 
    	white:  Fred Van der Vliet moves white knight from b5 to d6. White takes black pawn.
    	black:  Loek Van Wely moves black bishop from e6 to c4. Black takes white pawn.
    
    [31] expanded: 
    	white:  Fred Van der Vliet moves white pawn from e4 to e5.
    	black:  Loek Van Wely moves black queen from f6 to d8.
    
    [32] expanded: 
    	white:  Fred Van der Vliet moves white pawn from b4 to b5.
    	black:  Loek Van Wely moves black knight from a6 to b8.
    
    [33] expanded: 
    	white:  Fred Van der Vliet moves white queen from d2 to b4.
    	black:  Loek Van Wely moves black rook from d7 to d6. Black takes white knight.
    
    [34] expanded: 
    	white:  Fred Van der Vliet moves white pawn from e5 to d6. White takes black rook.
    	black:  Loek Van Wely moves black bishop from c4 to d3.
    
    [35] expanded: 
    	white:  Fred Van der Vliet moves white rook from c1 to c8. White takes black rook.
    	black:  Loek Van Wely moves black queen from d8 to c8. Black takes white rook.
    
    [36] expanded: 
    	white:  Fred Van der Vliet moves white rook from b1 to d1.
    	black:  Loek Van Wely moves black bishop from d3 to e2.
    
    [37] expanded: 
    	white:  Fred Van der Vliet moves white rook from d1 to c1.
    	black:  Loek Van Wely moves black queen from c8 to e8.
    
    [38] expanded: 
    	white:  Fred Van der Vliet moves white bishop from e3 to b6. White takes black pawn.
    	black:  Loek Van Wely moves black bishop from e2 to f3. Black takes white knight.
    
    [39] expanded: 
    	white:  Fred Van der Vliet moves white bishop from g2 to f3. White takes black bishop.
    	black:  Loek Van Wely moves black knight from h5 to f4. Black takes white pawn.
    
    [40] expanded: 
    	white:  Fred Van der Vliet moves white rook from c1 to e1.
    	black:  Loek Van Wely moves black bishop from g7 to e5.
    
    [41] expanded: 
    	white:  Fred Van der Vliet moves white rook from e1 to e5. White takes black bishop.
    	black:  Loek Van Wely moves black queen from e8 to e5. Black takes white rook.
    
    [42] expanded: 
    	white:  Fred Van der Vliet moves white queen from b4 to d4.
    	black:  Loek Van Wely moves black queen from e5 to b5. Black takes white pawn.
    
    [43] expanded: 
    	white:  Fred Van der Vliet moves white queen from d4 to f4. White takes black knight.
    	black:  Loek Van Wely moves black queen from b5 to b6. Black takes white bishop.
    
    [44] expanded: 
    	white:  Fred Van der Vliet moves white queen from f4 to f7. Check. White takes black pawn.
    	black:  Loek Van Wely moves black king from h7 to h8.
    
    [45] expanded: 
    	white:  Fred Van der Vliet moves white queen from f7 to f6. Check.
    	black:  Loek Van Wely moves black king from h8 to h7.
    
    [46] expanded: 
    	white:  Fred Van der Vliet moves white bishop from f3 to e4.
    	black:  Loek Van Wely moves black queen from b6 to a7.
    
    [47] expanded: 
    	white:  Fred Van der Vliet wins!
    	black:  Loek Van Wely resigns.
    
    
    
    Process finished with exit code 0
    

GOES

  • See if I can get a GAN running with the new parts. I am not convinced that the input vector and times series are set up right. I probably need to set up for testing that as a parameter as well.
  • Still, they seem reasonable. For testing, I have an input vector of 5 and 10 samples, like so:
    [[ 0.99611333]
      [-0.49462109]
      [-0.58444332]
      [ 0.98104957]
      [-0.23207803]]
    
     [[ 0.70418362]
      [ 0.35257367]
      [-0.99762846]
      [ 0.47774618]
      [ 0.60000333]]
  • My latent matrix is 4 wide by 10 samples, arranged like so:
    [  2.46776301  17.36723783  -3.05622169 -15.7807726 ]
     [  4.73444423 -13.03790398  -0.04382812 -17.16272464]
  • And my predicts seem reasonable, and they match the real data exactly, both from the Dense->CNN and the Dense versions
  • Dense (2 steps of 5-feature vector)
    [[-1.        ]
      [ 1.        ]
      [-1.        ]
      [-1.        ]
      [ 1.        ]]
    
     [[-0.845926  ]
      [ 0.98410994]
      [-0.9970485 ]
      [-0.99517673]
      [ 0.910765  ]]
  • Dense->CNN (2 steps of 5-feature vector)
    [[ 0.9974974 ]
      [-0.7852714 ]
      [-0.8944576 ]
      [ 0.99998605]
      [-0.34316158]]
    
     [[-0.9874317 ]
      [-0.90552104]
      [ 0.95992273]
      [ 0.8134167 ]
      [-0.94480175]]
  • And all the predicts from the detector have the same form of (10, 1):
    [[0.5464545 ]
     [0.5419694 ]
     [0.5464503 ]
     [0.5464593 ]
     [0.5464545 ]
     [0.5462216 ]
     [0.45328763]
     [0.541866  ]
     [0.48022035]
     [0.54643464]]
  • So I think I’m just going to try to build a OneDGAN2 class, evaluate that, and then if it’s working well, build a NoiseGAN2 class and use that for the paper/presentation
  • Back to being able to draw plots, which means that the model is being created without blowing up!

Noise_untrained

  • So I made some changes, basically added many more samples, played around with the size of the latent space and so forth. And I got a very unusual result when looking at the untrained model:

Noise_untrained

  • I think this may be related to the use of a dense layer between the latent data and the Conv1D. Need to do some more reading, I guess.