Skip to content

Instantly share code, notes, and snippets.

View standy66's full-sized avatar

Andrew Stepanov standy66

  • Quantum Light Capital
  • London, United Kingdom
View GitHub Profile
from agentnet.utils.persistence import save,load
def build_pretrained_spaceinvaders(observation_reshape):
""" a smaller version of DQN pre-trained for ~2 hours on GPU """
assert tuple(observation_reshape.output_shape) == (None, 3, 105, 80)
#main neural network body
conv0 = Conv2DLayer(observation_reshape,16,filter_size=(8,8),stride=(4,4),name='conv0')
conv1 = Conv2DLayer(conv0,32,filter_size=(4,4),stride=(2,2),name='conv1')
dense0 = DenseLayer(conv1,256,name='dense',nonlinearity=lasagne.nonlinearities.tanh)
with g.as_default():
print([v.name for v in tf.all_variables()])
W = [v for v in tf.all_variables() if v.name == "Conv/weights:0"][0]
W_val = sess.run(W)
fig, axes = plt.subplots(5, 5, figsize=(15, 15))
for i in range(5):
for j in range(5):
axes[i, j].imshow(W_val[:, :, 0, i * 5 + j], interpolation='nearest', cmap='gray')
plt.show()
@standy66
standy66 / mult.py
Created January 11, 2016 00:20
Python matrix multiplier
#! /usr/bin/env python3
import sys
def read_matrix(path):
A = []
with open(path) as f:
content = f.readlines()
for line in content:
idx1, idx2, other = line.split()
@standy66
standy66 / gen.py
Created January 11, 2016 00:19
Python matrix generator
#! /usr/bin/env python3
import sys
import random
width = int(sys.argv[1])
height = int(sys.argv[2])
for i in range(0, width):
for j in range(0, height):
channel = new FileInputStream(dbFilePath).getChannel();
ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
try {
while (buffer.remaining() > 0) {
int keySize = buffer.getInt();
byte[] key = new byte[keySize];
buffer.get(key);
int valueSize = buffer.getInt();
byte[] value = new byte[valueSize];
buffer.get(value);