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 | |
import random | |
import cv2 | |
import pandas as pd | |
import torch | |
from torch.utils.data import Dataset | |
from transformers import (BertTokenizerFast, PreTrainedTokenizerFast, | |
RobertaTokenizerFast) |
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 segmentation_models_pytorch.encoders import get_encoder | |
from .mil import MILPool | |
def make_net_li2018( | |
backbone, | |
n_out, | |
n_in=1, | |
n_dec_ch=512, | |
out_size=20, |
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 errno | |
import os | |
import time | |
from collections import defaultdict | |
from contextlib import ContextDecorator, contextmanager | |
from itertools import count | |
import torch | |
CUDA_ALLOC_FILE = os.path.expanduser('~/mlkit.alloc') |
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
""" | |
blocks until a specific time, | |
useful for planning to run a script at a specific time | |
usage: | |
python til.py 13:00 tomorrow && python script.py | |
""" | |
import dateparser | |
from datetime import datetime, timedelta |
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 tensorflow as tf | |
import numpy as np | |
tf.enable_eager_execution() | |
save_path = 'logs/test10' | |
graph = tf.Graph() | |
with graph.as_default(): | |
global_step = tf.train.create_global_step() | |
writer = tf.contrib.summary.create_file_writer(save_path) |
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 tensorflow as tf | |
import numpy as np | |
save_path = 'summary_path' | |
graph = tf.Graph() | |
with graph.as_default(): | |
global_step = tf.train.create_global_step() | |
writer = tf.contrib.summary.create_file_writer(save_path) | |
with writer.as_default(): | |
tf.contrib.summary.always_record_summaries() |
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 tensorflow.contrib.summary as summary | |
global_step = tf.train.get_or_create_global_step() | |
optimizer = tf.train.AdamOptimizer(lr).minimize(..., global_step=global_step) | |
writer = summary.create_file_writer('log') | |
writer.set_as_default() | |
summary.always_record_summaries() | |
with summary.record_summaries_every_n_global_steps(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
from select import select | |
import os | |
import time | |
import subprocess | |
from contextlib import contextmanager | |
@contextmanager | |
def pipe(): | |
r, w = os.pipe() |
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
class MyConv(Layer): | |
''' | |
Implemeting a Conv2D with strides=1, and 'valid' padding | |
''' | |
def __init__(self, filters, kernel, **kwargs): | |
self.filters = filters | |
self.k_h, self.k_w = kernel | |
super(MyConv, self).__init__(**kwargs) |
NewerOlder