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
#include<stdbool.h> | |
#include<stdio.h> | |
struct sim { | |
const int rng_seed; | |
const int num_item; | |
const int num_node; | |
const int num_svar; | |
const int num_time; |
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
def heun(y, t, dt): | |
d1 = dfun(y, t) | |
d2 = dfun(y + dt*d1, t + dt) | |
err = np.mean(np.abs((d1 - d2)))#/(1e-9+d2))) | |
return y + dt/2*(d1 + d2), err | |
def solve_adapt1(y0, ts, tol): | |
ys = [y0] | |
max_dt = dt = ts[1] - ts[0] | |
t0 = ts[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
import os | |
# use cpu for this | |
os.environ['CUDA_VISIBLE_DEVICES'] = '' | |
########################### numpy style | |
import numpy as np | |
n = 5 | |
size = 4 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 numpy as np | |
import torch | |
class MyModule(torch.nn.Module): | |
def add_param(self, key, shape): | |
val = torch.randn(*shape)/np.prod(shape) | |
setattr(self, key, torch.nn.Parameter(val)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder