Skip to content

Instantly share code, notes, and snippets.

View SrivastavaKshitij's full-sized avatar
💭
If you wait for luck to turn up, life becomes boring - Mikhail Tal

Kshitij Srivastava SrivastavaKshitij

💭
If you wait for luck to turn up, life becomes boring - Mikhail Tal
View GitHub Profile
@SrivastavaKshitij
SrivastavaKshitij / jupyter_notebook_remote.txt
Created April 24, 2017 15:26
Remote accessing Jupyter Notebook running on a server
This document is about running jupyter notebook on a server and accessing it on a local machine.
On the remote machine, start jupyter notebook
remote_user@remote_host$ ipython notebook --no-browser --port=8889
when the notebook will start, it will generate a token.
On the local machine, start SSH tunnel
@SrivastavaKshitij
SrivastavaKshitij / one_time_remote_access.txt
Last active April 24, 2017 15:29
Remote access by typing password only once
This document shows step by step procedure on how to SSH without using password everytime
Type the following commands:
1. cd .ssh
2. vim config
when you open config file, type the following:
host snake
@SrivastavaKshitij
SrivastavaKshitij / gist:1be3ca5f1fca9f2ba3de0724b51d5ef3
Created May 4, 2017 20:53
Running process remotely and independently

Running the program on server remotely

  • to be run sequentially
description command
run python script python xx.py
run the following command : this pauses the process CTRL + Z ( this works for ubuntu server)
put the process in background bg
@SrivastavaKshitij
SrivastavaKshitij / vim.txt
Created December 13, 2017 15:00
Vim settings
set nu
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@SrivastavaKshitij
SrivastavaKshitij / performance_metric.py
Created September 3, 2018 21:34
Performance metric
import numpy as np
def pf(output,target,metric=None):
TP = np.count_nonzero(data*target)
TN = np.count_nonzero((data - 1) * (target - 1))
FP = np.count_nonzero(data * (target - 1))
FN = np.count_nonzero((data - 1) * target)
precision = TP / (TP + FP)
recall = TP / (TP + FN)
F1 = 2 * precision * recall / (precision + recall)
accuracy = (TP+TN)/(TP+TN+FP+FN)
@SrivastavaKshitij
SrivastavaKshitij / pytorch_pf.py
Created September 3, 2018 23:38
performance metric in pytorch
import torch
def pf1(output,target,metric=None):
d = output.data
t = target.data
TP = torch.nonzero(d*t).size(0)
TN = torch.nonzero((d - 1) * (t - 1)).size(0)
FP = torch.nonzero(d * (t - 1)).size(0)
FN = torch.nonzero((d - 1) * t).size(0)
precision = TP / (TP + FP)
recall = TP / (TP + FN)
import torch
from torch import nn
class autoencoder(nn.Module):
def __init__(self,downsizing_factor=None,in_channels=1):
self.downsize = downsizing_factor
self.in_channels = in_channels
super(autoencoder,self).__init__()
conv_modules=[]
self.in_channels = self.in_channels
import torch
from torch import nn
class autoencoder(nn.Module):
def __init__(self,downsizing_factor=None,in_channels=1):
self.downsize = downsizing_factor
self.in_channels = in_channels
super(autoencoder,self).__init__()
conv_modules=[]
self.in_channels = self.in_channels
@SrivastavaKshitij
SrivastavaKshitij / .vimrc
Last active January 7, 2022 01:55
Vim settings
set tabstop=8
set expandtab
set softtabstop=4
set shiftwidth=4
filetype plugin indent on
set number
set backspace=indent,start
set hlsearch
@SrivastavaKshitij
SrivastavaKshitij / .tmux.conf
Created November 16, 2018 19:36
tmux configuration file
# Use C-o like we do in screen as action key
#unbind C-b
set -g prefix C-a
#bind-key C-b last-window
bind-key a send-prefix
bind-key C-n next-window
bind-key C-p previous-window
# Terminal emulator window title
set -g set-titles on