Skip to content

Instantly share code, notes, and snippets.

View FirefoxMetzger's full-sized avatar

Sebastian Wallkötter FirefoxMetzger

View GitHub Profile
import numpy as np
import sgf # pip install sgf -- simple parser for the file format
import timeit
def decode_position(pos_string):
# position in .sgf is char[2] and row-first, e.g. "fd"
positions = "abcdefghijklmnopqrs"
x = positions.index(pos_string[0])
y = positions.index(pos_string[1])
return y, x
@FirefoxMetzger
FirefoxMetzger / parser.py
Created April 5, 2018 21:14
A small parser with some visualization for go .sgf replays
import numpy as np
import sgf # pip install sgf -- simple parser for the file format
def decode_position(pos_string):
# position in .sgf is char[2] and row-first, e.g. "fd"
positions = "abcdefghijklmnopqrs"
x = positions.index(pos_string[0])
y = positions.index(pos_string[1])
return y, x
@FirefoxMetzger
FirefoxMetzger / model_comparison.py
Last active April 1, 2018 09:44
Comparing two small networks using dense layers. According to Keras' documentation both should be identical
from keras.models import Sequential
from keras.layers import Dense, Flatten
model1 = Sequential()
model1.add(Dense(1, input_shape=(10,10)))
model2 = Sequential()
model2.add(Flatten(input_shape=(10,10)))
model2.add(Dense(1))
@FirefoxMetzger
FirefoxMetzger / cifar10_res.py
Last active August 4, 2021 19:49
a residual network using Keras' Sequential() API training on CIFAR10
'''Train a simple residual network on the CIFAR10 small images dataset.
It gets to 75% validation accuracy in 25 epochs, and 79% after 50 epochs.
(it's still underfitting at that point, though).
'''
from __future__ import print_function
import keras
from keras.datasets import cifar10
from keras.preprocessing.image import ImageDataGenerator
@FirefoxMetzger
FirefoxMetzger / Residual_Layer.py
Created March 31, 2018 15:50
Create a residual layer in Keras to be used with Sequential() models
from keras.engine.topology import Layer
from keras.layers importActivation, Conv2D, Add
class Residual(Layer):
def __init__(self, channels_in,kernel,**kwargs):
super(Residual, self).__init__(**kwargs)
self.channels_in = channels_in
self.kernel = kernel
def call(self, x):
@FirefoxMetzger
FirefoxMetzger / faster_fully_connected_reader.py
Created February 16, 2018 06:54
A modification to the tensorflow how_to fully_connected_reader.py that significantly improves performance
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# 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,
@FirefoxMetzger
FirefoxMetzger / upload_data.py
Created January 17, 2018 08:17
How to insert scores to scoreboard
import requests
# to be filled in by you
token = "" # if you have signed up at https://scoreboard-190810.appspot.com
# you can find it on the top left corner of the page
environment = "Test-v0" # name of the environment the agent is for
data = {
"name": "My Agent Name", # you wrote it, you get to name it =)
"score": "1337", # replace with actual score
@FirefoxMetzger
FirefoxMetzger / fully_connected_reader.py
Created November 21, 2017 11:45
fully_connected_reader.py using Dataset instead of Queues to feed into Tensorflow
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# 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,
#!/bin/bash
docker-machine scp -r . myRegistry:~
docker-machine ssh myRegistry docker load -i registry.tar
docker-machine ssh myRegistry sudo cp -r certs /var/lib/boot2docker
docker-machine ssh myRegistry docker stack deploy --compose-file=docker-compose.yml registry
version: '3'
services:
registry:
image: registry:2
ports:
- "443:5000"
volumes:
- "/var/lib/boot2docker/certs:/certs"
- "registry_data:/data"