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 cv2 | |
import time | |
from datetime import datetime | |
import pathlib | |
save_gap = 1800 | |
done = False | |
while not done: |
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 time | |
from torch.multiprocessing import Process, Queue as mpQueue, set_start_method | |
from line_profiler import LineProfiler | |
def test(x): | |
for i in range(3): | |
if x == 1: | |
print(x) | |
time.sleep(0.1) | |
else: |
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 gc | |
import time | |
import numpy as np | |
def foo(repeat): | |
a = [] | |
for _ in range(repeat): | |
a.append(np.zeros((84, 84, 1))) | |
s = time.time() | |
return s |
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 io import BytesIO | |
from PIL import Image, ImageDraw, ImageFont | |
class schedule: | |
def __init__(self, fname): | |
self.talks = [] | |
with open(fname, 'r', encoding='utf-8') as f: | |
for line in f: | |
line = line.split() | |
time, line = line[0], ' '.join(line[1:]) |
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 gc | |
import time | |
from io import BytesIO | |
import multiprocessing | |
from multiprocessing.pool import ThreadPool | |
import torch | |
import requests | |
from PIL import Image | |
from torchvision import transforms |
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 random | |
import gym | |
import numpy as np | |
import tensorflow as tf | |
L2_REG = 1e-2 | |
LR = 1e-3 | |
class pg: | |
def __init__(self): |
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 random | |
import gym | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torch.distributions import Categorical | |
L2_REG = 1e-2 |
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 _batch_normalization(inp, is_train, name=None, is_conv=True): | |
now_mean, now_var = tf.nn.moments(inp, axes=[0, 1, 2] if is_conv else [0]) | |
if name is None: | |
name = str(time.time()) | |
gamma = tf.get_variable('gamma_%s' % name, shape=[inp.shape[-1]]) | |
beta = tf.get_variable('beta_%s' % name, shape=[inp.shape[-1]]) | |
ema = tf.train.ExponentialMovingAverage(decay=0.99) | |
def update(): | |
with tf.control_dependencies([ema.apply([now_mean, now_var])]): |
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 <cstdio> | |
#include <queue> | |
#include <cmath> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int depth(int a) | |
{ | |
int now = 3, res = 0, sum = 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
#include <cstdio> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int n, m, k; | |
vector<long long int> container; //raw data 저장 배열, 범위 [1...n] | |
vector<long long int> tree; // 세그먼트 트리, 루트는 1, 왼쪽 자식은 2i, 오른쪽 자식은 2i+1 | |
vector<long long int> lazy; // 현재 구간에 할당된 lazy값. 하위 구간을 참조해야 되면 0으로 바꾸고 밑으로 내려보냄 | |
/* |