Skip to content

Instantly share code, notes, and snippets.

View p208p2002's full-sized avatar

Philip p208p2002

View GitHub Profile
@p208p2002
p208p2002 / GPT Fine-tuning.ipynb
Last active August 2, 2021 08:10
#blog #gpt #gpt2 #nlp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json
if __name__ == "__main__":
docs = []
with open('./law200.json','r',encoding='utf-8') as f:
for line in f.readlines():
doc = json.loads(line)
docs.append(doc)
print(len(docs))
@p208p2002
p208p2002 / plink-plonk.js
Created February 17, 2020 23:23 — forked from tomhicks/plink-plonk.js
Listen to your web pages
import time
import progressbar
print('in range')
for i in progressbar.progressbar(range(20)):
time.sleep(0.02)
print('in list')
my_list = [1]*100
with progressbar.ProgressBar(max_value=len(my_list)) as bar:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
# ubnutu
# /etc/ssh/sshd_config
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
const path = require('path');
const express = require('express')
const app = express()
const port = 3000
// For Static File
app.use(express.static('public'))
// 404 Redirect to App(Front End Route will handle next)
app.get('*', function(req, res){
res.sendFile(path.join(__dirname+'/public/index.html'))
});
from gensim.models.doc2vec import Doc2Vec, TaggedDocument
import csv
import jieba
# jieba初始化
jieba.set_dictionary('dict/dict.txt.big')
jieba.load_userdict('dict/my_dict')
jieba.initialize()
# 讀入waimai_10k_tw.csv,並且使用jieba斷詞
"""
pytorch CrossEntropyLoss 用法
"""
import torch
import torch.nn as nn
import math
loss = nn.CrossEntropyLoss()
input = torch.randn(1, 5, requires_grad=True)
target = torch.empty(1, dtype=torch.long).random_(5)
output = loss(input, target)
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://free.nchc.org.tw/ubuntu/ xenial main restricted
# deb-src http://free.nchc.org.tw/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://free.nchc.org.tw/ubuntu/ xenial-updates main restricted
# deb-src http://free.nchc.org.tw/ubuntu/ xenial-updates main restricted