Skip to content

Instantly share code, notes, and snippets.

View rkwitt's full-sized avatar
🎯
Focusing

Roland Kwitt rkwitt

🎯
Focusing
View GitHub Profile
"""
Simple example of using pytorch to build a linear regression model.
"""
import torch
from torch.autograd import Variable
from torch import optim
import sys
@rkwitt
rkwitt / UCSD_Ped_Counting_Dataset.py
Created September 25, 2017 09:42
Data loading for the UCSD pedestrian counting dataset
class UCSD(Dataset):
"""UCSD pedestrian counting data."""
def __init__(self, data_dir, annotation_dir, transform=None):
self.file_list = []
self.file_cnts = []
files = glob.glob(
os.path.join(
@rkwitt
rkwitt / cs4all-10242016-recursion.c
Created October 24, 2016 12:05
Simple example to demonstrate recursion and stack build up and tear down
int g(int x, int y) {
if (y > 0)
return g(x, y - 1) + 1 ;
else
return x;
}
int main() {
int a;
@rkwitt
rkwitt / cs4all-10172016-gp.c
Created October 24, 2016 12:03
Example to demonstrate MIPS32 GP
int a = 1111;
int main() {
a = 3333;
}
@rkwitt
rkwitt / cs4all-10242016-fun.c
Created October 24, 2016 12:02
Simple function call to demonstrate stack
int f(int a, int b, int c)
{
int c;
c = a + b;
return c;
}
int main()
{
int a;
@rkwitt
rkwitt / test_negative_type_simple.m
Last active August 29, 2015 14:11
Indefiniteness of p-Wasserstein and Bottleneck distance based kernels
function [pos_ev_idx,neg_ev_idx,seed,data] = test_negative_type_simple(options)
% TEST_NEGATIVE_TYPE_SIMPLE evaluate the eigenvalues of Gram matrices
%
% This function evaluates the number of positive/negative eigenvalues
% of the Gram matrix M, either constructed from the (1) q-Wasserstein
% distance or (2) the bottleneck distance.
%
% Both distances lead to nonnegative (symmetric) Gram matrices and
% the question is if the Gram matrices are (conditionally) negative
% definite (see suppl. material).
2014-09-29 09:29:04 +0200
make
all
clang -O -c -o vecLibFort.o vecLibFort.c
clang -shared -O -DVECLIBFORT_INTERPOSE -o libvecLibFortI.dylib -O vecLibFort.c \
-Wl,-reexport_framework -Wl,Accelerate \
-install_name /usr/local/lib/libvecLibFortI.dylib
ar -cru libvecLibFort.a vecLibFort.o
2014-09-29 09:29:04 +0200
make
all
clang -O -c -o vecLibFort.o vecLibFort.c
clang -shared -O -DVECLIBFORT_INTERPOSE -o libvecLibFortI.dylib -O vecLibFort.c \
-Wl,-reexport_framework -Wl,Accelerate \
-install_name /usr/local/lib/libvecLibFortI.dylib
ar -cru libvecLibFort.a vecLibFort.o
@rkwitt
rkwitt / kw-techtip-04-03-2013-p1.py
Last active December 15, 2015 18:49
Kitware TechTip 04-03-2013 Part 1: Graph construction from a binary adjacency matrix and a vertex label file.
"""kw-techtip-04-03-2013-p1.py
Simple example of how to construct a graph from a {0,1} adjacency matrix and a
file with vertex labels.
Usage
-----
$ python kw-techtip-04-03-2013-p1.py <AdjacencyFile> <LabelFile>
@rkwitt
rkwitt / kw-techtip-04-03-2013-p2.py
Last active December 15, 2015 18:49
Kitware TechTip 04-03-2013 Part 2: Computing fine-structure graph features
"""kw-techtip-04-03-2013-p2.py
Fine-structure analysis of a graph.
Usage
-----
Assuming that the file "graph.txt" generated by kw-techtip-04-03-2013-p1.py
resides in "/tmp", run