Skip to content

Instantly share code, notes, and snippets.

View kunalghosh's full-sized avatar

Kunal Ghosh kunalghosh

  • Aalto University
  • Helsinki
View GitHub Profile
import gpytorch
import numpy as np
import joblib
from pathlib import Path
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
class ExactGPModel(gpytorch.models.ExactGP):
def __init__(self, train_x, train_y, likelihood):
#Define network
6 class Net(nn.Module):
7 def __init__(self, output_spectra_length):
8 super(Net, self).__init__()
9 self.conv1_1 = nn.Conv2d(1, 22, 3, padding=1)
10 self.conv1_2 = nn.Conv2d(22, 22, 3, padding=1)
11 self.conv1_3 = nn.Conv2d(22, 22, 3, padding=1)
12 self.conv2_1 = nn.Conv2d(22, 47, 3, padding=1)
13 self.conv2_2 = nn.Conv2d(47, 47, 3, padding=1)
14 self.conv2_3 = nn.Conv2d(47, 47, 3, padding=1)
@kunalghosh
kunalghosh / plot_K_hat_vs_D_fr_swa.py
Created January 19, 2020 14:49
Python stacktrace
(tensorflow-env) [ghoshk1@x86_64-conda_cos6-linux-gnu]/scratch/work/ghoshk1/SWAVI_tfp/Linear_Regression_QMC% python plot_K_hat_vs_D_fr_swa.py
2020-01-17 17:18:42.228790: I tensorflow/core/platform/profile_utils/cpu_utils.cc:101] CPU Frequency: 2793045000 Hz
2020-01-17 17:18:42.229921: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x561889248eb0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-01-17 17:18:42.229970: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
File "plot_K_hat_vs_D_fr_swa.py", line 148, in <module>
init, max_iterations=1000)
File "/home/ghoshk1/.local/lib/python3.6/site-packages/tensorflow_probability/python/optimizer/lbfgs.py", line 260, in minimize
parallel_iterations=parallel_iterations)[0]
File "/home/ghoshk1/.local/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py", line 574, in new_func
import torch
import torch.nn as nn
from torch.distributions import transforms
class Param(nn.Module):
def __init__(self, var, transform=transforms.identity_transform):
super(Param).__init__(self, var)
self.transform = transform
self.var_ = var
Homebrew
Emacs
Spacemacs
anaconda
# for matplotlib backend
brew install pyqt
conda install pyqt5
# for spell check in spacemacs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kunalghosh
kunalghosh / lasso.m
Created June 15, 2016 10:33
Big Data SHOTGUN
clear all;
format long;
load('Mug32_singlepixcam.mat'); lambda=0.05;%lambda = 1.0e-010;
[N,d] = size(A);
A_org=A;y_org=y;lambda_org=lambda;
% Choose # of parallel updates. get_Popt()
% x = rand(d,1);
x_org = zeros(d,1);
condition = true;
%non normalised function
.loc 4 126 0 is_stmt 1
vxorps %xmm15, %xmm15, %xmm15 # tmp488
.LBE2494:
.LBE2493:
.LBE2492:
.LBB2523:
.loc 4 219 0
vmulps (%rax), %ymm14, %ymm0 # MEM[base: _709, offset: 0B], D.85250, D.85242
.LBE2523:
.LBB2524:
@kunalghosh
kunalghosh / vae_parmesan.py
Last active May 14, 2016 08:53
Variational Auto-encoder Implementation using Parmesan
import theano
theano.config.floatX = 'float32'
import theano.tensor as T
import math
import time
import sys
import os
import numpy as np
#include "cp.h"
#include <vector>
#include <algorithm>
#include <cmath>
#include <iterator>
void correlate(int ny, int nx, const float* data, float* result) {
int row1=0;
int res_row,res_col;