Skip to content

Instantly share code, notes, and snippets.

View karlnapf's full-sized avatar

Heiko Strathmann karlnapf

View GitHub Profile
@karlnapf
karlnapf / main.cpp
Created April 9, 2012 21:35
Code to reproduce MKL memorsy errors
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2011 Heiko Strathmann
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/
@karlnapf
karlnapf / gist:5371082
Last active December 16, 2015 03:38
how to sample a Gaussian given covariance or precision with symamd
% samples from N(mu, C) in case type=='cov', and from N(mu, C^(-1)) in case
% type=='prec'. z is optional and must be drawn from N(0,I), inds is a
% permutations vector that is applied to C before sampling (doesnt effect
% the output, just efficiency, smyamd is used as default)
function sample=gaussian_sampler_symamd(mu, C, type, z, inds)
if nargin<3
type='prec';
end
if nargin <4
@karlnapf
karlnapf / trivial-crash-example.dat
Created May 2, 2013 14:20
Minimal program that has problem with streaming features
#include <shogun/io/streaming/StreamingAsciiFile.h>
#include <shogun/features/streaming/StreamingSparseFeatures.h>
using namespace shogun;
int main(int argc, char *argv[])
{
init_shogun();
CStreamingAsciiFile *file=new CStreamingAsciiFile("trivial-crash-example.dat");
@karlnapf
karlnapf / gist:5722391
Created June 6, 2013 15:25
LARS segfault
from numpy.ma.core import reshape, mean
from shogun.Features import RegressionLabels, RealFeatures
from shogun.Regression import LeastAngleRegression, LinearRidgeRegression, LeastSquaresRegression
from shogun.Evaluation import CrossValidation, CrossValidationResult, \
CrossValidationSplitting, MeanSquaredError
import time
n=250
n_class=6
dim=274 * 100 * 12
@karlnapf
karlnapf / gist:5723230
Created June 6, 2013 17:21
TParameter serialization
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Heiko Strathmann
*/
#include <shogun/lib/config.h>
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Heiko Strathmann
*/
#include <shogun/lib/config.h>
@karlnapf
karlnapf / gist:5787975
Created June 15, 2013 12:34
probe a graph colouring
function [V,colours] = probe( colours)
%% function [V] = probe(A,p)
% Creates a probing matrix based on a graph colouring of A using the
% algorithm in "J. Tang and Y. Saad, A probing method for computing the diagonal of the matrix
% inverse" (2010).
%
% REQUIRES: Matgraph toolbox http://www.ams.jhu.edu/~ers/matgraph/
%
% Input: colours - A graph colouring (of A^p probably)
%
function [d,V] = det_Krylov_preconditioned(A,P,precomputed, tol,maxiter)
n = length(A);
V = probe(precomputed.colouring);
d= 0.0;
parfor iii=1:size(V,2)
workerNo = get(getCurrentTask,'ID');
fprintf('det_Krylov_preconditioned %d/%d\n', iii, size(V,2));
[tmp,iter]=ratKrylov01_preconditioned(A,V(:,iii),P,precomputed.wsq,precomputed.dzdt,precomputed.const,tol,maxiter);
d = d + V(:,iii)'*tmp;
@karlnapf
karlnapf / gist:5968042
Created July 10, 2013 16:56
Shogun Gradient Model Selection example bugs
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Heiko Strathmann
*/
#include <shogun/lib/config.h>
{
"metadata": {
"name": "shogun_gp_classification"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{