Skip to content

Instantly share code, notes, and snippets.

View abaybektursun's full-sized avatar
💫
Grind

Abay Bektursun abaybektursun

💫
Grind
View GitHub Profile
use pyo3::prelude::*;
use pyo3::buffer::PyBuffer;
use std::thread;
use std::sync::mpsc;
use std::sync::Mutex;
use std::sync::Arc;
use std::net::{TcpListener, TcpStream};
use std::io::prelude::*;
@abaybektursun
abaybektursun / blog_lm1b_3.py
Last active July 9, 2021 02:38
Word sequence embeddings
def forward(sentence):
# Tokenize characters and words
word_ids = [vocab.word_to_id(w) for w in sentence.split()]
char_ids = [vocab.word_to_char_ids(w) for w in sentence.split()]
if sentence.find('<S>') != 0:
sentence = '<S> ' + sentence
for i in xrange(len(word_ids)):
inputs[0, 0] = word_ids[i]
@abaybektursun
abaybektursun / blog_lm1b_2.py
Created March 24, 2018 00:27
Initialize needed variables
# For saving demo resources, use batch size 1 and step 1.
BATCH_SIZE = 1
NUM_TIMESTEPS = 1
MAX_WORD_LEN = 50
# File Paths
vocab_file = "language_model/data/vocab-2016-09-10.txt"
save_dir = "language_model/output"
pbtxt = "language_model/data/graph-2016-09-10.pbtxt"
ckpt = "language_model/data/ckpt-*"
@abaybektursun
abaybektursun / blog_lm1b_1.py
Created March 24, 2018 00:17
Import and some libraries and declare graph loader function
import os
import sys
import numpy as np
import tensorflow as tf
# From lm_1b
import language_model.lm_1b.data_utils as data_utils
from six.moves import xrange
from google.protobuf import text_format
@abaybektursun
abaybektursun / setup_lm_1b.sh
Created March 23, 2018 23:54
Download and setup pre-trained lm_1b model files
#!/bin/bash
# Assume you are in my_project directory
newdir="language_model"
if [ ! -d "$newdir" ]; then
mkdir "$newdir"
fi
cd "$newdir"
@abaybektursun
abaybektursun / logic.java
Last active March 10, 2018 03:59
Correction for Caleb
if (object.edible == true){
dog.eat(object);
}
else{
dog.tearToShreds(object);
}
@abaybektursun
abaybektursun / blog_tensorflow_variable_sequence_classification.py
Last active September 6, 2019 09:26 — forked from danijar/blog_tensorflow_variable_sequence_classification.py
TensorFlow Variable-Length Sequence Classification (Updated)
# Updated to work with TF 1.4
# Working example for my blog post at:
# http://danijar.com/variable-sequence-lengths-in-tensorflow/
import functools
import sets
import tensorflow as tf
from tensorflow import nn
def lazy_property(function):