Skip to content

Instantly share code, notes, and snippets.

View Oktai15's full-sized avatar
:electron:

Oktai Tatanov Oktai15

:electron:
View GitHub Profile
@Oktai15
Oktai15 / em_algo.py
Last active January 21, 2021 10:01
Differentiable EM-algorithm
import torch
import torch.nn as nn
import torch.optim as optim
from torch.distributions.normal import Normal
num_gaussian = 6
gaussian_dim = 1
device = torch.device("cuda")
@Oktai15
Oktai15 / simple-nn-caffe.prototxt
Created May 7, 2018 10:00
Caffe: simple example
name: "SimpleCaffeNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 10 dim: 1 dim: 28 dim: 28 } }
}
layer {
name: "fc1"
type: "InnerProduct"
@Oktai15
Oktai15 / simple-recurrent-block-pytorch.py
Last active April 30, 2018 11:23
PyTorch: simple example of recurrent block
import torch
h0 = torch.randn(10)
x = torch.randn(5, 10)
h = [h0]
for i in range(5):
h_i = h[-1] * x[i]
h.append(h_i)
@Oktai15
Oktai15 / simple-cond-tf.py
Last active April 30, 2018 10:19
TensorFlow: simple example conditional
# update for https://gist.github.com/Oktai15/4b6617b916c0fa4feecab35be09c1bd6
a = tf.constant(10)
data = tf.placeholder(tf.float32, shape=(data_size, input_size))
h1_w1 = tf.placeholder(tf.float32, shape=(input_size, hidden1_output))
h2_w1 = tf.placeholder(tf.float32, shape=(input_size, hidden1_output))
def first(): return tf.matmul(data, h1_w1)
def second(): return tf.matmul(data, h2_w1)
@Oktai15
Oktai15 / simple-nn-pytorch.py
Created April 30, 2018 09:04
PyTorch: simple example
import torch
import torch.nn as nn
import torch.nn.functional as fun
data_size = 10
input_size = 28 * 28
hidden1_output = 200
output_size = 1
@Oktai15
Oktai15 / simple-nn-keras.py
Last active April 30, 2018 09:02
Keras: simple example
import numpy as np
import tensorflow as tf
data_size = 10
input_size = 28 * 28
hidden1_output = 200
output_size = 1
data = np.random.randn(data_size, input_size)
@Oktai15
Oktai15 / simple-nn-tf.py
Last active April 30, 2018 10:09
TensorFlow: simple example
import numpy as np
import tensorflow as tf
data_size = 10
input_size = 28 * 28
hidden1_output = 200
output_size = 1
data = tf.placeholder(tf.float32, shape=(data_size, input_size))