This file contains 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); |
This file contains 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 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 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 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 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
\documentclass[a4paper,12pt]{article} | |
\usepackage[T2A]{fontenc} | |
%\usepackage[utf8]{inputenc} % older versions of ucs package | |
\usepackage[utf8x]{inputenc} % more recent versions (at least>=2004-17-10) | |
\usepackage[russian]{babel} | |
\usepackage{amsmath} | |
\sloppy % Hyphenation is a problem.. |
This file contains 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
import numpy as np | |
import matplotlib.pyplot as plt | |
from IPython.display import Audio | |
from scipy.signal import spectrogram | |
sample_rate = 8000 | |
t = np.arange(0, 10, 1.0/sample_rate) | |
x = t % (2 / sample_rate) | |
plt.figure(figsize=(16, 6), dpi=200) |
This file contains 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
import sys, re, pymystem3 | |
mystem = pymystem3.Mystem() | |
def stem(s): | |
return [(e['text'].strip(), \ | |
e['analysis'][0]['lex'] \ | |
if 'analysis' in e and len(e['analysis']) > 0 else '', \ | |
re.match('^([A-Z]+)', e['analysis'][0]['gr']).group(0) \ | |
if 'analysis' in e and len(e['analysis']) > 0 else '', \ |
This file contains 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 tf.name_scope("subgraph_1"): | |
with tf.variable_scope(tf.get_variable_scope(), resue=False): | |
y_1 = output(x_1) | |
with tf.name_scope("subgraph_2"): | |
with tf.variable_scope(tf.get_variable_scope(), reuse=True): | |
y_2 = output(x_2) |
This file contains 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
""" | |
Based on example here: https://gist.github.com/awni/56369a90d03953e370f3964c826ed4b0 | |
""" | |
import numpy as np | |
import math | |
import collections | |
NEG_INF = -float("inf") |
OlderNewer