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 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
import torch | |
import torch.nn as nn | |
import torch.nn.parallel | |
class DCGAN_D(nn.Container): | |
def __init__(self, isize, nz, nc, ndf, ngpu, n_extra_layers=0): | |
super(DCGAN_D, self).__init__() | |
self.ngpu = ngpu | |
assert isize % 16 == 0, "isize has to be a multiple of 16" |
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
#adjust learning rate policy by callbacks | |
def scheduler(epoch): | |
if epoch == 5: | |
model.lr.set_value(.02) | |
return model.lr.get_value() | |
change_lr = LearningRateScheduler(scheduler) | |
model.fit(x_embed, y, nb_epoch=1, batch_size = batch_size, show_accuracy=True, | |
callbacks=[chage_lr]) |
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
# ### python_ncut_lib.py | |
# Copyright (C) 2010 R. Cameron Craddock ([email protected]) | |
# | |
# This script is a part of the pyClusterROI python toolbox for the spatially constrained clustering of fMRI | |
# data. It provides the library functions for performing normalized cut clustering according to: | |
# | |
# Shi, J., & Malik, J. (2000). Normalized cuts and image segmentation. IEEE Transactions on Pattern Analysis | |
# and Machine Intelligence, 22(8), 888-905. doi: 10.1109/34.868688. | |
# | |
# Yu, S. X., & Shi, J. (2003). Multiclass spectral clustering. Proceedings Ninth IEEE International Conference |
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
"Pathogen | |
execute pathogen#infect() | |
syntax on | |
filetype plugin indent on | |
"NERDtree | |
" open NERDTree with ctrl+n | |
map <F2> :NERDTreeToggle<CR> | |
" close vim if the only window left open is a NERDTree | |
autocmd bufenter * if(winnr("$")==1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif |
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
#设置前缀为Ctrl + a | |
unbind ^b | |
set -g prefix 'C-a' | |
#将r 设置为加载配置文件,并显示信息 | |
bind r source-file ~/.tmux.conf \; display-message "Config reloaded" | |
#up | |
bind-key k select-pane -U | |
#down | |
bind-key j select-pane -D |
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
from math import ceil | |
import numpy as np | |
from sklearn.cluster import KMeans | |
import theano | |
import theano.tensor as T | |
def compute_reps(extract_fn, X, chunk_size): | |
"""Compute representations for input in chunks.""" | |
chunks = int(ceil(float(X.shape[0]) / chunk_size)) |
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
-- Two dashes start a one-line comment. | |
--[[ | |
Adding two ['s and ]'s makes it a | |
multi-line comment. | |
--]] | |
---------------------------------------------------- | |
-- 1. Variables and flow control. | |
---------------------------------------------------- |
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
def create_conf_matrix(expected, predicted, n_classes): | |
m = np.zeros((n_classes, n_classes)) | |
for pred, exp in zip(predicted, expected): | |
m[pred][exp] += 1 | |
return m | |
def calc_accuracy(conf_matrix): | |
t = sum(sum(l) for l in conf_matrix) | |
return sum(conf_matrix[i][i] for i in range(len(conf_matrix))) / t |
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
class BatchNormLayer(lasagne.layers.Layer): | |
def __init__(self, incoming, b=lasagne.init.Constant(0.), g=lasagne.init.Constant(1.), | |
W=lasagne.init.Normal(0.05), nonlinearity=relu, **kwargs): | |
super(BatchNormLayer, self).__init__(incoming, **kwargs) | |
self.nonlinearity = nonlinearity | |
k = self.input_shape[1] | |
if b is not None: | |
self.b = self.add_param(b, (k,), name="b", regularizable=False) | |
if g is not None: | |
self.g = self.add_param(g, (k,), name="g") |