Skip to content

Instantly share code, notes, and snippets.

View cbaziotis's full-sized avatar

Christos Baziotis cbaziotis

View GitHub Profile
@mir4ef
mir4ef / git-remove
Created June 30, 2016 17:59
Remove a file/folder from git repo, but keep local
git rm --cached file-name.txt
git rm -r --cached folder-name
git commit -m "removed file-name and/or folder-name"
git push origin master or branch-name
@MaximumEntropy
MaximumEntropy / moses_tokenizer.py
Last active November 11, 2017 10:23
Simple python interface to the moses tokenizer
import subprocess
import sys
tokenizer_path = sys.argv[1] # Path to the moses tokenizer mosesdecoder/scripts/tokenizer.perl
text = sys.argv[2] # Text to be tokenized
lang = sys.argv[3] # Input language ex: en, fr, de
pipe = subprocess.Popen(["perl", tokenizer_path, '-l', lang, text], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
pipe.stdin.write(text.encode('utf-8'))
pipe.stdin.close()
from keras.engine.topology import Layer
from keras import initializations
from keras import backend as K
class Attention(Layer):
'''Attention operation for temporal data.
# Input shape
3D tensor with shape: `(samples, steps, features)`.
# Output shape
2D tensor with shape: `(samples, features)`.
# This is inspired by the fantastic guide https://github.com/saiprashanths/dl-setup
# I have just updated the python-related commands so that everything works in Python 3.
# Tested on Xubuntu 16.04.
# First of all let's update the repos:
sudo apt-get update
# Only if you have a CUDA-compatible Nvidia card, install CUDA.
# Check on the Nvidia website what is the latest driver version which supports your card.
# At the time of this writing it was 367.
@georgepar
georgepar / ipynb2pdf.py
Created October 29, 2017 19:43
A script to convert an ipython notebook to pdf with support for greek language
#!/usr/bin/env python3
"""
Credits https://github.com/ivanychev/learning/blob/master/Python/ipynb2pdf/ipynb2pdf.py
Current version of Jupyter doesn't support pdf exporting when it comes to
greek language in the document. To fix this, current script has born.
It requires nbconvert as long as jupyter to be installed.
Author: Sergey Ivanychev
@tokestermw
tokestermw / rnn_viz_keras.py
Last active April 6, 2019 18:40
Recurrent Neural Network (RNN) visualizations using Keras.
from __future__ import print_function
from keras import backend as K
from keras.engine import Input, Model, InputSpec
from keras.layers import Dense, Activation, Dropout, Lambda
from keras.layers import Embedding, LSTM
from keras.optimizers import Adam
from keras.preprocessing import sequence
from keras.utils.data_utils import get_file
from keras.datasets import imdb
@fchollet
fchollet / new_stacked_rnns.py
Last active August 13, 2019 15:23
New stacked RNNs in Keras
import keras
import numpy as np
timesteps = 60
input_dim = 64
samples = 10000
batch_size = 128
output_dim = 64
# Test data.
@filitchp
filitchp / OpenCV-3.1-Ubuntu-16.04-Cuda-8.md
Last active December 12, 2019 21:36
Installing OpenCV 3.1 on Ubuntu 16.04 with Cuda 8 support

This is a guide for installing OpenCV 3.1 on Ubuntu 16.04 with Cuda 8 support. This has been tested using a system with a GeForce GTX 1060 and on one with a GeForce GTX 1080.

Nvidia Drivers with Compiz

Install Nvidia drivers

# Start clean
sudo apt purge nvidia-*
# Add the PPA
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
@njellinas
njellinas / autoencoder_extra.py
Created October 26, 2017 14:46
Two Keras Layer-Class definitions for implementing Weight-Tying and for loading pretrained weights in Deep Autoencoders
import keras.backend as K
from keras.layers import Layer
from keras.legacy import interfaces
from keras.engine import InputSpec
from keras import activations, initializers, regularizers, constraints
class DenseTransposeTied(Layer):
@interfaces.legacy_dense_support
import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
import torch.nn.functional as F
import matplotlib.pyplot as plt
import numpy as np