Skip to content

Instantly share code, notes, and snippets.

deepanshululla / thread_safe_queue.cpp
Last active Apr 27, 2022
View thread_safe_queue.cpp
#include <exception>
#include <memory>
#include <mutex>
#include <queue>
struct EmptyQueueException : std::exception {
const char * what() const throw() {
return "Empty queue";
stormraiser /
Last active Mar 4, 2021
Danbooru Faces dataset

Danbooru Faces v0.1


This dataset contains ~443k anime face images of size 256x256 drawn by ~7,000 artists, obtained from Danbooru


We first downloaded JSON files of all existing posts numbered from 1 to 2,800,000 using their API. We filtered the posts by the following criteria:

import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers=1):
super(RNN, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
View halide.cpp
#include "Halide.h"
#include "Halide/tools/halide_image_io.h"
#include <iostream>
// This code calculates a block based mean on some a-priori known image-dimensions (1 uint8_t channel)
// An example image to process:
// No customized scheduling within this code, but the SO-answer gives some recommendation!
int main(int argc, char **argv) {
Halide::Buffer<uint8_t> input = Halide::Tools::load_image("TestImages/block_example.png");
shamatar /
Last active Jan 14, 2022
Keras ( implementation of Recurrent Weighted Average, as described in Follows original implementation in Tensorflow from 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
nigeljyng /
Last active Feb 10, 2021 — forked from cbaziotis/
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [] "Hierarchical Attention Networks for Document Classification"
class AttentionWithContext(Layer):
Attention operation, with a context/query vector, for temporal data.
Supports Masking.
Follows the work of Yang et al. []
"Hierarchical Attention Networks for Document Classification"
by using a context vector to assist the attention
# Input shape
3D tensor with shape: `(samples, steps, features)`.
# Output shape
andrewssobral /
Created Mar 26, 2017 — forked from karpathy/
Natural Evolution Strategies (NES) toy example that optimizes a quadratic function
A bare bones examples of optimizing a black-box function (f) using
Natural Evolution Strategies (NES), where the parameter distribution is a
gaussian of fixed standard deviation.
import numpy as np
# the function we want to optimize
kashif /
Last active Jun 5, 2017
Initial implementation of Evolution Strategies
import numpy as np
import gym
from gym.spaces import Discrete, Box
from gym.wrappers import Monitor
from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
# ================================================================
# Policies
agibson73 / PulseTouchCollectionViewCell
Created Mar 12, 2017
Just a UICollectionview cell animation on touch although it could be performed on any uiview.
View PulseTouchCollectionViewCell
import UIKit
@IBDesignable class PulseTouchCollectionViewCell: UICollectionViewCell {
@IBInspectable var scaleFactor : CGFloat = 1.3
@IBInspectable var animationColor : UIColor =
@IBInspectable var startingOpacity : Float = 0.2
@IBInspectable var animationDuration : Double = 0.8
View Adversarial variational bayes toy example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.