Skip to content

Instantly share code, notes, and snippets.

View alperyeg's full-sized avatar
:electron:
Charging

Alper alperyeg

:electron:
Charging
View GitHub Profile
from torch.nn.functional import one_hot
import torch
def enkf_lstsq(ens, model_out, obs, gamma, batch_s, ensemble_size):
for i in range(batch_s):
g_tmp = model_out[:, :, i]
Cpp = torch.tensordot(
(g_tmp - g_tmp.mean(0)), (g_tmp - g_tmp.mean(0)), dims=([0], [0])) / ensemble_size
Cup = torch.tensordot(
@alperyeg
alperyeg / simple_network_pytorch.py
Last active October 9, 2019 18:14
simple network in pytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch import optim
from torchvision import datasets, transforms
torch.manual_seed(1)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
@alperyeg
alperyeg / load_mnist.py
Last active August 19, 2022 11:39
Loading MNIST dataset with scikit learn
from sklearn.datasets import fetch_openml
from sklearn.utils import check_random_state
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
def fetch_data(test_size=10000, randomize=False, standardize=True):
X, y = fetch_openml('mnist_784', version=1, return_X_y=True)
if randomize:
random_state = check_random_state(0)
@alperyeg
alperyeg / line_prof_cch_results.txt
Last active February 4, 2016 01:08
profiling of elephant.spike_train_correlation.cross_correlation_histogram
Timer unit: 1e-06 s
Total time: 10.4797 s
Function: _cch_memory at line 397
Line # Hits Time Per Hit % Time Line Contents
==============================================================
397 @profile
398 def _cch_memory(st_1, st_2, win, mode, norm, border_corr, binary, kern):
399