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 bresenham(startPoint, endPoint): | |
| startPoint = [int(startPoint[0]),int(startPoint[1]),int(startPoint[2])] | |
| endPoint = [int(endPoint[0]),int(endPoint[1]),int(endPoint[2])] | |
| steepXY = (abs(endPoint[1] - startPoint[1]) > abs(endPoint[0] - startPoint[0])) | |
| if(steepXY): | |
| startPoint[0], startPoint[1] = startPoint[1], startPoint[0] | |
| endPoint[0], endPoint[1] = endPoint[1], endPoint[0] |
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
| params = list(net.parameters()) | |
| # get only weight from last layer(linear) | |
| weight_softmax = np.squeeze(params[-2].cpu().data.numpy()) | |
| def returnCAM(feature_conv, weight_softmax, class_idx): | |
| size_upsample = (128, 128) | |
| bz, nc, h, w = feature_conv.shape | |
| output_cam = [] | |
| for idx in class_idx: | |
| cam = weight_softmax[class_idx].dot(feature_conv.reshape( (nc, h*w))) |
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
| learning_rate = 0.005 # 이것을 너무 높게 설정하면 폭발할 수 있고 너무 낮으면 학습이 되지 않을 수 있습니다. | |
| def train(category_tensor, line_tensor): | |
| hidden = rnn.initHidden() | |
| rnn.zero_grad() | |
| for i in range(line_tensor.size()[0]): | |
| output, hidden = rnn(line_tensor[i], hidden) |
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
| #!/bin/bash | |
| # Script for installing tmux on systems where you don't have root access. | |
| # tmux will be installed in $HOME/local/bin. | |
| # It's assumed that wget and a C/C++ compiler are installed. | |
| # exit on error | |
| set -e | |
| TMUX_VERSION=2.2 |
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
| #!/bin/bash | |
| # Script for installing tmux on systems where you don't have root access. | |
| # tmux will be installed in $HOME/local/bin. | |
| # It's assumed that wget and a C/C++ compiler are installed. | |
| # exit on error | |
| set -e | |
| TMUX_VERSION=2.2 |
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 multiprocessing | |
| import string | |
| from multiprocessing_mapreduce import SimpleMapReduce | |
| def file_to_words(filename): | |
| """Read a file and return a sequence of (word, occurances) values. | |
| """ | |
| STOP_WORDS = set([ | |
| 'a', 'an', 'and', 'are', 'as', 'be', 'by', 'for', 'if', 'in', |
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 get_line(start, end): | |
| """Bresenham's Line Algorithm | |
| Produces a list of tuples from start and end | |
| >>> points1 = get_line((0, 0), (3, 4)) | |
| >>> points2 = get_line((3, 4), (0, 0)) | |
| >>> assert(set(points1) == set(points2)) | |
| >>> print points1 | |
| [(0, 0), (1, 1), (1, 2), (2, 3), (3, 4)] | |
| >>> print points2 |
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 | |
| from parallel import DataParallelModel, DataParallelCriterion | |
| model = BERT(args) | |
| model = DataParallelModel(model) | |
| model.cuda() | |
| criterion = nn.NLLLoss() | |
| criterion = DataParallelCriterion(criterion) |
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
| #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| ## Created by: Hang Zhang | |
| ## ECE Department, Rutgers University | |
| ## Email: zhang.hang@rutgers.edu | |
| ## Copyright (c) 2017 | |
| ## | |
| ## This source code is licensed under the MIT-style license found in the | |
| ## LICENSE file in the root directory of this source tree | |
| ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
NewerOlder