Skip to content

Instantly share code, notes, and snippets.

@lolz0r
lolz0r / basis.py
Created January 22, 2019 17:06
Learned basis function, pytorch
class ConvSeluSVD(nn.Module):
def __init__(self, inputSize, outputSize, stride=1, maxpool=False, ownBasis=False):
super(ConvSeluSVD, self).__init__()
self.inputSize = inputSize
self.outputSize = outputSize
self.stride = stride
self.params = Parameter( torch.Tensor(outputSize * inputSize, 1,3).normal_(0, .02))
@johnhw
johnhw / umap_sparse.py
Last active January 6, 2024 16:09
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@kevinzakka
kevinzakka / data_loader.py
Last active April 19, 2024 23:42
Train, Validation and Test Split for torchvision Datasets
"""
Create train, valid, test iterators for CIFAR-10 [1].
Easily extended to MNIST, CIFAR-100 and Imagenet.
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4
"""
import torch
import numpy as np
@mshkrebtan
mshkrebtan / webex-ubuntu.md
Last active October 28, 2022 15:23
Run Cisco Webex on 64-bit Ubuntu 16.04

Run Cisco Webex on 64-bit Ubuntu 16.04

With Audio and Screen Sharing Enabled

Enable support for 32-bit executables

Add the i386 architecture to the list of dpkg architectures :

sudo dpkg --add-architecture i386
from lasagne.nonlinearities import *
from lasagne.layers import Layer
class SpatialSoftmaxLayer(Layer):
"""
Softmax layer that computes the softmax over pixels in the same location,
i.e., over the channel axis. This layer will automatically use the CuDNN
version of this softmax if it is available.
Parameters
def sample_gumbel(shape, eps=1e-20):
"""Sample from Gumbel(0, 1)"""
U = tf.random_uniform(shape,minval=0,maxval=1)
return -tf.log(-tf.log(U + eps) + eps)
def gumbel_softmax_sample(logits, temperature):
""" Draw a sample from the Gumbel-Softmax distribution"""
y = logits + sample_gumbel(tf.shape(logits))
return tf.nn.softmax( y / temperature)
@josyb
josyb / oo.md
Last active November 20, 2022 10:07
Object Oriented Design in MyHDL

There is a web-page where Adam Taylor lists 10 alternative FPGA development languages: http://www.eetimes.com/document.asp?doc_id=1329857 On some languages the OO-word was used ... I commented that the only thing I have seen so far from these languages is that they are (truly) class based but that I haven't seen any real example. Yet, as I did not study them to their deepest extent, having not enough time and too much other work ...

I already use class-based design for my MyHDL work, see my gist https://gist.github.com/josyb/afd84c9a06fdec77f2fd, but this is not OO as none of these classes have been subclassed.

In stead of doing some real work today (Sat Oct 22nd 2016), I decided to give OO in MyHDL a try. You can see the results in the two next files.

@josyb
josyb / dynconn.py
Last active October 9, 2018 09:23
Exploring improved structural design - Part 1
'''
Created on 29 Dec 2015
@author: Josy
'''
from __future__ import print_function
import random
import myhdl
@hasherezade
hasherezade / brainfuck.l
Created May 28, 2015 18:28
BrainfuckToC (Flex & Bison)
%{
#include "brainfuck.tab.h"
#include <string.h>
#include <stdlib.h>
void error()
{
fprintf(stdout, "Plik niepoprawny pod wzglêdem leksykalnym. Linia: %d\n", yylineno);
exit(1);
}