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 cv2 | |
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
output_size = 501 | |
flow = np.zeros((output_size, output_size, 2), dtype=np.float32) | |
flow[:, :, 0] = np.arange(-(output_size // 2), output_size // 2 + 1) | |
flow[:, :, 1] = np.arange(-(output_size // 2), output_size // 2 + 1)[:, np.newaxis] |
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 torch | |
batch_size = 3 | |
seq_len = 20 | |
vocab_size = 4 | |
emb_size = 6 | |
conv_length = 2 | |
num_conv_kernel = 30 | |
channel_in = 1 # of course for text... |
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 evaluate_ECE(data_iter, net, device, M=15): | |
net.eval() | |
bins, n = [0.0 for _ in range(M)], 0 | |
with torch.no_grad(): | |
for X_batch, y_batch in data_iter: | |
p_batch = torch.exp(lsoftmax(net(X_batch.to(device)))) | |
y_hat_batch = net(X_batch.to(device)).argmax(dim=1) | |
for p, y_hat, y in zip(p_batch.numpy(), y_hat_batch.numpy(), y_batch.numpy()): |
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
ai_service_enable = "false" | |
ai_service_mode = "0" | |
ai_service_pause = "false" | |
ai_service_source_lang = "0" | |
ai_service_target_lang = "0" | |
ai_service_url = "http://localhost:4404/" | |
all_users_control_menu = "true" | |
apply_cheats_after_load = "false" | |
apply_cheats_after_toggle = "false" | |
aspect_ratio_index = "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
/* | |
* Copyright (C) 2020-2021 Andi Zhang <[email protected]> | |
*/ | |
#include <iostream> | |
using namespace std; | |
class MyInt { | |
public: |
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 sys | |
import time | |
# sys.setrecursionlimit(10000) | |
def qsort(a): | |
if len(a) <= 1: return a | |
pivot = random.choice(a) | |
left = qsort([x for x in a if x < pivot]) |
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
from collections import deque | |
class TrieNode: | |
def __init__(self, endWord = False, parent = None, char = ''): | |
# to record duplicate words | |
self.count = int(endWord) | |
self.children = dict() | |
# fail pointer of Aho Corasick Automaton | |
self.fail = None | |
# recording the parent in order to output the matched concept |