Skip to content

Instantly share code, notes, and snippets.

@sergei-mironov
sergei-mironov / demo_ll.py
Created November 28, 2019 10:29
demo_ll.py
@tf.function
def model(x, w0, b0, w1, b1, ...):
x = tf.nn.sigmoid(tf.matmul(x, w0) + b0)
x = tf.nn.sigmoid(tf.matmul(x, w1) + b1)
return x
def train(...):
for (x,y) in train_ds:
with tf.GradientTape() as tape:
loss = compute_loss(model(x, ...), y)
@sergei-mironov
sergei-mironov / demo_ll.py
Created November 28, 2019 10:29
demo_ll.py
@tf.function
def model(x, w0, b0, w1, b1, ...):
x = tf.nn.sigmoid(tf.matmul(x, w0) + b0)
x = tf.nn.sigmoid(tf.matmul(x, w1) + b1)
return x
def train(...):
for (x,y) in train_ds:
with tf.GradientTape() as tape:
loss = compute_loss(model(x, ...), y)
@sergei-mironov
sergei-mironov / demo_func.py
Last active November 28, 2019 10:21
demo_func.py
inputs = keras.Input(shape=(784,), name='digits')
x = layers.Dense(64, activation='relu', name='dense_1')(inputs)
x = layers.Dense(64, activation='relu', name='dense_2')(x)
outputs = layers.Dense(10, activation='softmax', name='predictions')(x)
model = keras.Model(inputs=inputs, outputs=outputs)
model.fit(...)
@sergei-mironov
sergei-mironov / custom_transformer21.py
Last active November 21, 2019 08:08
TF Official bert customization, new design
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import copy
import json
import math
import six
import itertools
@sergei-mironov
sergei-mironov / custom_transformer.py
Created November 20, 2019 14:38
TF Official bert customization, old design
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import json
import math
import six
import tensorflow as tf
import itertools
@sergei-mironov
sergei-mironov / minimal.py
Last active October 30, 2019 21:14
minimal.py
# Instructions
# 1. Load this file in IPython
# 2. call `run()`
# 3. Interrupt it with Ctrl+C
# 4. See no global state changed
from typing import Any,Optional
from time import sleep
class Model:
@sergei-mironov
sergei-mironov / train_assign.py
Created October 26, 2019 22:01
Global assignment followed by an errot
import os
import json
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
assert tf.version.VERSION.startswith('2.')
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_virtual_device_configuration(
gpus[0],
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5.5*1024)])
@sergei-mironov
sergei-mironov / vkontakte_m3u8_downloader.sh
Last active October 21, 2023 20:04
vkontakte_m3u8_downloader.sh
#!/bin/sh
# VKontakte *m3u8 downloader
# Worked at the time of writing
mkdir /tmp/m3u8
set -e -x
cd /tmp/m3u8
rm *
@sergei-mironov
sergei-mironov / Streets_GInfo_Msk.html
Last active October 5, 2019 21:09
Streets_GInfo_Msk.html
This file has been truncated, but you can view the full file.
<html>
<head>
<script>
function clearclass(item, cls) {
item.classList.remove(cls);
}
function setclass(item, cls) {
item.classList.add(cls);
@sergei-mironov
sergei-mironov / SPb.md
Last active September 28, 2019 10:19
SPb.md
Район Название Дома
0 Адмиралтейский 1-я Красноармейская улица 1/21А, 1/21Д, 1/21Ж, 1/21З, 1/21К, 2, 2В, 3-5-7-9А, 3-5-7-9Б, 4, 6, 6Б, 8-10, 8-10Б, 11, 11В, 12, 13, 13Б, 13В, 14, 15, 16, 18, 18Б, 20, 22, 24, 24Б
1 Адмиралтейский 10-я Красноармейская улица 3, 3б, 4, 5, 5а, 5Б, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16А, 17, 19, 19А, 19Б1, 20, 20а, 21, 22, 23, 24, 26
2 Адмиралтейский 11-я Красноармейская улица 1, 2, 4, 5/13, 6, 7, 8, 9, 10, 11, 11А, 11В, 11Ж, 12, 13, 14, 15а, 15аБ, 15Б, 16, 18, 20, 22, 26, 28
3 Адмиралтейский 12-я Красноармейская улица 1, 2, 3, 4, 5, 6, 6Б, 6Г, 7, 8, 8Б, 8В, 10, 11, 12, 12Б, 13, 14, 14В, 15, 16Г, 16Н, 17, 19, 21, 23, 24, 25, 27, 29, 32, 33А, 34, 36, 37, 40
4 Адмиралтейский [13-я Красноармейская улица](http://spb.ginfo.ru/ulicy