This file contains hidden or 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 tqdm import tqdm | |
pbar = tqdm(range(50)) | |
for epoch in pbar: # loop over the dataset multiple times | |
running_loss = 0.0 | |
# sample a bunch of timesteps | |
Ts = np.random.randint(1,num_diffusion_timesteps, size=training_steps_per_epoch) | |
for _, t in enumerate(Ts): | |
# produce corrupted sample |
This file contains hidden or 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 denoise_with_mu(denoise_model, x_t, t, list_alpha, list_alpha_bar, DATA_SIZE, device): | |
""" | |
Denoising function considering the denoising models tries to model the posterior mean | |
""" | |
alpha_t = list_alpha[t] | |
beta_t = 1 - alpha_t | |
alpha_bar_t = list_alpha_bar[t] | |
mu_theta = denoise_model(x_t,t) | |
This file contains hidden or 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 q_sample(x_start, t, list_bar_alphas, device): | |
""" | |
Diffuse the data (t == 0 means diffused for 1 step) | |
""" | |
alpha_bar_t = list_bar_alphas[t] | |
mean = alpha_bar_t*x_start | |
cov = torch.eye(x_start.shape[0]).to(device) | |
cov = cov*(1-alpha_bar_t) |
This file contains hidden or 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
// Update State | |
// hook position | |
bobberBarPos = Helper.Reflection.GetField<float>(bar, "bobberBarPos").GetValue(); | |
// fish position | |
bobberPosition = Helper.Reflection.GetField<float>(bar, "bobberPosition").GetValue(); | |
// hook speed | |
bobberBarSpeed = Helper.Reflection.GetField<float>(bar, "bobberBarSpeed").GetValue(); | |
// amount of green bar filled | |
distanceFromCatching = Helper.Reflection.GetField<float>(bar, "distanceFromCatching").GetValue(); |
This file contains hidden or 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
replayMemory[updateCounter,0] = OldState[0]; | |
replayMemory[updateCounter,1] = OldState[1]; | |
replayMemory[updateCounter,2] = OldState[2]; | |
replayMemory[updateCounter,3] = NewState[0]; | |
replayMemory[updateCounter,4] = NewState[1]; | |
replayMemory[updateCounter,5] = NewState[2]; | |
replayMemory[updateCounter,6] = reward; | |
replayMemory[updateCounter,7] = actionBuffer? 1 : 0; |
This file contains hidden or 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
[HarmonyPatch(typeof(Game1), "isOneOfTheseKeysDown")] | |
class IsButtonDownHack | |
{ | |
// ... | |
// some important stuff | |
// ... | |
// change function return value to true | |
// makes the game think a mouse left button click ocurred | |
__result = true; |
This file contains hidden or 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
public int Update(double[] currentState) | |
{ | |
Tensor<double> input = new DenseTensor<double>(new[] {3}); | |
input[0] = currentState[0]; | |
input[1] = currentState[1]; | |
input[2] = currentState[2]; | |
// Setup inputs and outputs |
This file contains hidden or 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
@app.route('/',methods=['GET']) | |
def generate(): | |
# Since Flask forks the python process to answer for requests | |
# we need to do this to avoid errors with tensorflow | |
tf.reset_default_graph() | |
# Start tf session and load model into memory | |
sess = gpt2.start_tf_sess(threads=1) | |
gpt2.load_gpt2(sess) |
This file contains hidden or 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
; Equal? | |
;numbers | |
(test (v*s-v (interpS '(equal? 3 2))) (numV 0)) | |
(test (v*s-v (interpS '(equal? (+ 3 2) 5))) (numV 1)) | |
;closures | |
(test (v*s-v (interpS '(equal? (lambda x (car x)) (lambda y (car y))))) (numV 0)) | |
(test (v*s-v (interpS '(equal? (lambda x (car x)) (lambda x (car x))))) (numV 1)) | |
;boxes |