Skip to content

Instantly share code, notes, and snippets.

Avatar

binTang rabintang

  • Tencent, Shenzhen
  • Shenzhen, China
View GitHub Profile
@rabintang
rabintang / torchtext_dataset_example.py
Last active Nov 10, 2017
torchtext dataset example
View torchtext_dataset_example.py
from torchtext import data
class DatasetDemo(data.Dataset):
def __init__(self, fields, path=None, examples=None, **kwargs):
if examples is None:
examples = []
for line in file(path):
parts = line.split("\t")
target = parts[0]
@rabintang
rabintang / tensorflow_rename_variables.py
Created Jul 24, 2017 — forked from batzner/tensorflow_rename_variables.py
Small python script to rename variables in a TensorFlow checkpoint
View tensorflow_rename_variables.py
import sys, getopt
import tensorflow as tf
usage_str = 'python tensorflow_rename_variables.py --checkpoint_dir=path/to/dir/ ' \
'--replace_from=substr --replace_to=substr --add_prefix=abc --dry_run'
def rename(checkpoint_dir, replace_from, replace_to, add_prefix, dry_run):
checkpoint = tf.train.get_checkpoint_state(checkpoint_dir)
View crf.py
#!/usr/bin/python
# crf.py (by Graham Neubig)
# This script trains conditional random fields (CRFs)
# stdin: A corpus of WORD_POS WORD_POS WORD_POS sentences
# stdout: Feature vectors for emission and transition properties
from collections import defaultdict
from math import log, exp
import sys
@rabintang
rabintang / GoogleSpellingAPI
Last active Dec 29, 2015
利用Google提供的API来对输入的词做拼写检查,并得到来自Google返回的建议
View GoogleSpellingAPI
# -*- coding: utf-8 -*-
import time
import os
import sys
import urllib2,urllib
import HTMLParser
import xml.dom.minidom
import xml.etree.ElementTree as ET
@rabintang
rabintang / gist:5975472
Created Jul 11, 2013
C#的Email邮件发送系统,简单易用
View gist:5975472
/*****************************************************************/
* 功能:发送自定义电子邮件,可以用于在系统发送自定义系统邮件。
/*****************************************************************/
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
namespace XFish.Utils
{
@rabintang
rabintang / Generate_Thumbnail.py
Last active Dec 18, 2015
使用python生成缩略图,支持遍历整个文件夹中指定图片格式的图片
View Generate_Thumbnail.py
#-*-!/usr/bin/env python-*-
#-*-coding=utf-8-*-
from PIL import Image
import os
import sys
import fnmatch
import logging
class ThumbnailGenerator:
@rabintang
rabintang / Atopk SQL File
Created Jun 20, 2013
zen cart的Atopk模板的空数据库文件
View Atopk SQL File
-- phpMyAdmin SQL Dump
-- version 3.4.11.1deb1
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2013 年 06 月 18 日 23:36
-- 服务器版本: 5.5.29
-- PHP 版本: 5.4.6-1ubuntu1.1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
View weiboLogin.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib
import urllib2
import cookielib
import base64
import re
import json