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 functools | |
def my_collate(batch, use_shared_memory=False): | |
r"""Puts each data field into a tensor with outer dimension batch size""" | |
error_msg = "batch must contain tensors, numbers, dicts or lists; found {}" | |
elem_type = type(batch[0]) | |
if isinstance(batch[0], torch.Tensor): | |
out = None | |
if use_shared_memory: |
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 | |
#set -x | |
# Shows you the largest objects in your repo's pack file. | |
# Written for osx. | |
# | |
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ | |
# @author Antony Stubbs | |
# | |
# Found on https://stackoverflow.com/questions/10622179/how-to-find-identify-large-files-commits-in-git-history |
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 random | |
import torch | |
class DynamicNet(torch.nn.Module): | |
def __init__(self, D_in, H, D_out): | |
super(DynamicNet, self).__init__() | |
self.backbone = torch.nn.Linear(D_in, H) | |
self.head1 = torch.nn.Linear(H, D_out) | |
self.head2 = torch.nn.Linear(H, D_out) |
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
# Generates aliases for .bashrc that allow easy toggling of CUDA_VISIBLE_DEVICES | |
# The printf is to name the tmux pane with which GPUs are available | |
ALIAS_STR = 'alias {name}=\'printf "\\033]2;%s\\033\\\\" "GPU: {gpu_list}"; export CUDA_VISIBLE_DEVICES="{gpu_list}"\'' | |
ngpu = 8 | |
for i in range(ngpu): | |
print(ALIAS_STR.format(name="g" + str(i), gpu_list=str(i))) | |
for i in range(ngpu-1): |
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
public void postData() { | |
// Create a new HttpClient and Post Header | |
HttpClient httpclient = new DefaultHttpClient(); | |
HttpPost httppost = new HttpPost("https://www.metamind.io/language/classify") | |
httppost.setHeader("Authorization: Basic", "YOUR API KEY"); | |
try { | |
// Add your data | |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); | |
nameValuePairs.add(new BasicNameValuePair("classifier_id", 155)); |