This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |