Skip to content

Instantly share code, notes, and snippets.

@gf712
gf712 / Matern_test.ipynb
Created May 3, 2020 17:40
Tests for Matern kernel and respective gradients
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gf712
gf712 / cartesian_product.cpp
Created December 9, 2019 16:50
Cartesian product C++
#include <vector>
#include <iostream>
#include <tuple>
template <typename T>
void print(const std::vector<T>& vec)
{
for (const auto& el: vec)
std::cout << el << ", ";
std::cout << "\n";
import numpy as np
import shogun as sg
from sklearn import datasets
X, y = datasets.load_breast_cancer(True)
y[y==0] = -1
feat = sg.features(X.T)
kernel1 = sg.kernel("GaussianKernel")
#include <shogun/base/init.h>
#include <shogun/base/some.h>
#include <shogun/features/Features.h>
#include <shogun/io/File.h>
#include <shogun/io/SerializableAsciiFile.h>
#include <shogun/kernel/Kernel.h>
#include <shogun/labels/Labels.h>
#include <shogun/lib/DynamicObjectArray.h>
#include <shogun/lib/SGVector.h>
#include <shogun/machine/Machine.h>
@gf712
gf712 / index_to_type.cpp
Last active January 25, 2019 18:27
Store types in C++ and access them via enum/int
#include <iostream>
#include <cxxabi.h>
// compile: g++ -std=c++14 index_to_type.cpp -o index_to_type
// demangle types for console output
std::string demangled_type_helper(const char *name) {
size_t length;
int status;
char *demangled = abi::__cxa_demangle(name, nullptr, &length, &status);
@gf712
gf712 / cosine_annealing_adaptive_lr.py
Last active July 23, 2018 14:41
Ever find yourself stuck in a valley and can't find the way out? Try cosine annealing with cycles!
import keras
import keras.backend as K
import numpy as np
# keras version of adaptive learning with cosine annealing
# with cycles inspired by http://course.fast.ai/lessons/lesson2.html
class CosineAnnealingAdaptiveLRScheduler(keras.callbacks.Callback):