This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
NewerOlder