Skip to content

Instantly share code, notes, and snippets.

View cutlass90's full-sized avatar

Nazar Shmatko cutlass90

View GitHub Profile
@cutlass90
cutlass90 / Test.md
Last active July 9, 2016 08:46 — forked from tridemax/Test.md
Deep learning engineer test

##Terms Get the latest rnn_cell.py from TensorFlow distribution. There is mi_linear.py attached to this gist, which is equivalent to function linear from rnn_cell.py but implements Multiplicative Integration with Recurrent Neural Networks (http://arxiv.org/pdf/1606.06630v1.pdf).

To complete the test, modify rnn_cell.py (set the name like mi_rnn_cell.py) to use Multiplicative Integration instead of classic approach in all types of RNNs, rename all modified classes (like LSTMCell -> MILSTMCell), update all the comments with proper namings and parameters description (imagine this file should be commited to TensorFlow repository).

To ease the requirements, features like sharding of weight matrices in LSTMCell could be stripped from modified implementation. For example, provided mi_linear function accepts only two parameters instead of parameters list. So it's ok to simplify where seems applicable but please do not strip peepholes from LSTMCell.

Prepare comparative tests (MIGRUCell vs GR

import os
import argparse
import fnmatch
import numpy as np
import scipy
from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.vgg19 import preprocess_input
from keras.models import Model
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
with tf.variable_scope('scope_name'):
x = tf.ones([2, 5])
labels = tf.ones([2,10])
out = tf.layers.dense(x, 10)
cost = tf.nn.sigmoid_cross_entropy_with_logits(labels=labels, logits=out)
with tf.variable_scope('optimizer_graph'):
from keras.layers import TimeDistributed, Input, Dense, Lambda
from keras.models import Model
import tensorflow as tf
import numpy as np
def foo(x):
print('Shape of x must be [2, 4] !!!')
x = Lambda(lambda x: tf.Print(x, [tf.shape(x)], message='Print shape of x = '))(x)
return Dense(5)(x)
""" This script contain base function for face processing. """
import os
import gzip
import pickle
from multiprocessing import Pool
import math
import glob
from shutil import copyfile
@cutlass90
cutlass90 / embedding_visualisation_in_tensorboard.py
Created August 8, 2019 14:17
example of how to create embedding visualisation in tensorboard
import os
import tensorflow as tf
from tensorflow.contrib.tensorboard.plugins import projector
def main(save_path, vectors, metadata):
"""
:param save_path: str, dir to save results
:param vectors: 2D ndarray, axis 0 is samples, axis 1 is data
from kornia.filters import get_gaussian_kernel
from torch import nn
import torch
import torch.nn.functional as F
class ConsistencyLoss(nn.Module):
def __init__(self, kernel_size, kernel_sigma, device):
super().__init__()
self.device = device
from imageio import imread, imsave
from skimage.transform import warp
from reflect_face_lib import RFrame
from reflect_face_lib.utils import crop_image
from reflect_cv_tools.nn.utils import tensor2img, img2tensor
from reflect_alignment_neural import NeuralAlignment
from reflect_alignment_neural.utils import param2theta, theta2param
import numpy as np
import cv2
aligner = NeuralAlignment()