Skip to content

Instantly share code, notes, and snippets.

View X4's full-sized avatar
🤖

X4 X4

🤖
  • Dubai, UAW
  • 08:28 (UTC +04:00)
  • X @x4aes
View GitHub Profile
@shamatar
shamatar / rwa.py
Last active January 14, 2022 20:17
Keras (keras.is) implementation of Recurrent Weighted Average, as described in https://arxiv.org/abs/1703.01253. Follows original implementation in Tensorflow from https://github.com/jostmey/rwa. Works with fixed batch sizes, requires "batch_shape" parameter in input layer. Outputs proper config, should save and restore properly. You are welcome…
from keras.layers import Recurrent
import keras.backend as K
from keras import activations
from keras import initializers
from keras import regularizers
from keras import constraints
from keras.engine import Layer
from keras.engine import InputSpec
@seuliufeng
seuliufeng / tf_beam_decoder.py
Created February 2, 2017 23:44 — forked from nikitakit/tf_beam_decoder.py
Tensorflow Beam Search
"""
Beam decoder for tensorflow
Sample usage:
```
from tf_beam_decoder import beam_decoder
decoded_sparse, decoded_logprobs = beam_decoder(
cell=cell,
@vzhong
vzhong / Search.py
Created October 17, 2016 02:15
Basic search algorithms
"""
backtracking extended list informed
Depth First Search: y y n
Breadth First Search: n y n
Hill Climbing y y y
Beam Search: y y y
"""
import heapq
@udibr
udibr / beamsearch.py
Last active October 4, 2021 11:50
beam search for Keras RNN
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen):
"""for every sample, calculate probability for every possible label
you need to supply your RNN model and maxlen - the length of sequences it can handle
"""
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty)
return rnn_model.predict(data, verbose=0)
def beamsearch(predict=keras_rnn_predict,
@alexserver
alexserver / rest-basics.md
Created October 28, 2015 18:56
REST basics, Theory, Principles, and examples.

RESTful API know-how

Motivation

I place my learning process in this document with 2 motives:

  1. To have a quick guide whenever I lost the track of knowledge.
  2. To share the knowledge with anyone wants to learn RESTful APIs

1. Before, some theory

@alexserver
alexserver / increase_swap.sh
Created October 27, 2015 15:55
A shell script that sets a 4gb swap file. This is useful for vagrant machines.
#!/bin/sh
# size of swapfile in megabytes
swapsize=4000
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
@X4
X4 / nodejs-pi-setup.sh
Created March 23, 2015 20:22
Setup NodeJS on Raspberry Pi 2 in < 5 Minutes
Prerequisites:
==============
1. Raspbian
2. Raspberry Pi (2)
sudo apt-get update
sudo apt-get upgrade
cd
## Source: http://node-arm.herokuapp.com/
@dasjoe
dasjoe / check_smart.sh
Last active November 20, 2018 09:53
Check SMART values for ata-* disks
#!/bin/bash
DIR='/dev/disk/by-id/'
#DIR='/dev/disk/by-vdev/'
#DIR='/dev/disk/by-path/'
PREFIX='ata-*'
#PREFIX='pci-*'
#PREFIX='*'
@frankbaele
frankbaele / GruntFile
Last active December 31, 2015 12:19
libsass grunt + bourbon
module.exports = function (grunt) {
"use strict";
var neat = require('node-neat').includePaths;
// Config...
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {
port: 9001,
@funkotron
funkotron / docker_create_treeio.sh
Last active December 18, 2019 17:56
Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance.
#!/bin/bash
# Description: Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance
# Also requires postgresql client tools http://www.postgresql.org/download/linux/ubuntu/
# Run chmod +x to make this file executable then run it: ./docker_create_treeio.sh
# Author: Adam Awan
# Email: adam@tree.io
# Set the port to forward for Tree.io
TREEIO_PORT="80"