Skip to content

Instantly share code, notes, and snippets.

View ThiagoLira's full-sized avatar

ThiagoLira

View GitHub Profile
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
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)
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)
// 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();
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;
[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;
@ThiagoLira
ThiagoLira / update.cs
Created January 18, 2022 17:24
update function
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
@ThiagoLira
ThiagoLira / app.py
Last active November 3, 2019 16:24
@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)
@ThiagoLira
ThiagoLira / testes.rkt
Last active November 2, 2017 16:37
Test cases for Racket
; 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