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
#coding: utf-8 | |
#demo of beam search for seq2seq model | |
import numpy as np | |
import random | |
vocab = { | |
0: 'a', | |
1: 'b', | |
2: 'c', | |
3: 'd', |
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 ScopeExit: | |
def __init__(self, revert_exec=False): | |
self.revert_exec = revert_exec | |
self.cbs = [] | |
def add_cb(self, cb): | |
self.cbs.append(cb) | |
def del_cb(self, cb): | |
used = 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
def custom_min(data): | |
assert len(data) >= 1 | |
if len(data) <= 0: | |
return data,0 | |
min_idx = 0 | |
min_data = data[min_idx] | |
for i,item in enumerate(data): | |
if item < min_data: | |
min_data = item | |
min_idx = i |
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
# coding: utf-8 | |
import sys | |
import uuid | |
import json | |
import traceback | |
import winreg | |
from PyQt5.QtCore import QFile, QTimer, Qt, QDateTime, QSettings, QPoint, QSize | |
from PyQt5.QtWidgets import QApplication, QMainWindow, QGroupBox, QLineEdit, QTextEdit, QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QLabel, QDateTimeEdit, QMenuBar, QAction |
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
//std headers | |
#include <fstream> | |
#include <iostream> | |
//lib headers | |
#include <gif_lib.h> | |
#define USING_NEW_GIF_LIB defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 | |
cv::Mat imread_gif(const std::string& filename, const int flags) | |
{ | |
std::ifstream stream(filename, std::ios::in | std::ios::binary); |
OlderNewer