This file contains hidden or 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
""" | |
Use torch.cuda.amp in PyTorch for mixed precision training. | |
This method mixes 32-bit and 16-bit data to reduce memory use and speed up model training, | |
without much loss in accuracy. | |
It takes advantage of the quick computing of 16-bit data and controls precision by handling specific operations in 32-bit. | |
This approach offers a balance between speed and accuracy in training models. | |
""" | |
import torch | |
from torch.cuda.amp import autocast, GradScaler |
This file contains hidden or 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
#RNN data sizes: | |
# x.size() = [64x1000] | |
f[0] = self.get_f(dag[-1][0].name) # activation func | |
c[0] = F.sigmoid(self.w_xc(x) + F.linear(h_prev, self.w_hc, None)) | |
h[0] = (c[0]*f[0](self.w_xh(x) + F.linear(h_prev, self.w_hh, None)) + | |
(1 - c[0])*h_prev) | |
#h_prev.size() = [64x1000] | |
#self.w_hc.size() = [1000,1000] |
This file contains hidden or 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
function emd!(A,B) | |
@assert(size(A) == size(B)) | |
cost = 0 | |
last_bin = length(A) | |
for bin = 1:last_bin | |
delta = A[bin]-B[bin] | |
if(delta < 0) #more in B than in A | |
num_to_move = abs(delta) | |
next_bin = bin+1 | |
#search to the right for place to move 'package' |
This file contains hidden or 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
# 32-bit fixed point; parameter `f` is the number of fraction bits | |
function create_mask(wp,fp) | |
(2^wp-1)<<fp + (2^fp-1) | |
end | |
abstract FixedPoint <: Real | |
abstract Fixed <: FixedPoint | |
#abstract Ufixed <: FixedPoint # unsigned variant | |
immutable FixedPt{wp,fp} <: Fixed |
This file contains hidden or 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
src_smO0 id ie =104 | |
Readytodisabe icache. | |
Jump to secend Boot. | |
0.131] | |
U-Bot 201109-rc1-00003-ge89b14-dity (Ja 0 2014 - 12:5733) llwinner Technology | |
[ 0.140version:1.10 | |
[ 0.44]pmus ready | |
[ 0o |
This file contains hidden or 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
c2_v | |
[ 0.271]after set, dcdc2 mcdc3_vol =l 3_vol = 2800 | |
ldo4_vol = 2800 | |
power_start = 0 | |
sto mno key fet start | |
draa_set end | |
[ dnn'titialize ther n_key:boot_init_gpio) | |
DRV_DISP_In opened | |
[ 0.521p.output_type=4 | |
[ 0.525womode = .2]NAND: NANt |
This file contains hidden or 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
set tabstop=2 | |
set smarttab | |
set shiftwidth=2 | |
set autoindent | |
set expandtab | |
set backspace=start,indent | |
set guifont=Inconsolata\ 14 | |
set hlsearch | |
syntax on | |
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | |
This file contains hidden or 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
(* compile with: | |
corebuild -pkg async,unix test_async.native | |
*) | |
open Sys | |
open Async.Std | |
open Core | |
let (r,w) = Pipe.create () | |
(* producer *) |
This file contains hidden or 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
type 'a tree = Empty | Leaf of 'a | Node of 'a tree * 'a * 'a tree ;; | |
let rec tree_map f tree = | |
let rec aux t = match t with | |
| Empty -> Empty | |
| Leaf value -> Leaf (f value) | |
| Node (l,value,r) -> Node ( aux l , f value, aux r) in | |
aux tree | |
let rec preorder_print_tree tree = |
This file contains hidden or 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
"set guifont= Droid\ Sans\ Mono\ Slashed | |
"set guifont=Inconsolata:m12 | |
set guifont=Inconsolata\ 12 | |
"set guifont=Droid\ Sans\ Mono\ Slashed:h16 | |
colorscheme desert | |
execute pathogen#infect() | |
let s:ocamlmerlin=substitute(system('opam config var share'),'\n$','','''') . "/ocamlmerlin" | |
execute "set rtp+=".s:ocamlmerlin."/vim" | |
execute "set rtp+=".s:ocamlmerlin."/vimbufsync" |
NewerOlder