Skip to content

Instantly share code, notes, and snippets.

@nudles
nudles / how-to.markdown
Last active January 19, 2021 03:59 — forked from markjlorenz/how-to.markdown
Reverse Proxy Tunneling with an amazon EC2. Poor-mans gotomypc, teamviewer, etc.

Reverse Port Tunneling with EC2

Reverse port tunneling is used to give a user outside of a networks firewall accesst to a computer inside the firewall where direct SSH connections aren't allowed. It works by the in-firewall computer SSH'ing to a middleman computer that then forwards incomming SSH connections on a given port to the firewalled computer.

Setup the middleman

  • Get an ubuntu EC2 instance
  • Download it's security keys (both in-firewall and out-firewall computers will need the private key)
  • Setup the security group to allow connections on port 10002
  • SSH into the middleman and add: GatewayPorts yes to /etc/ssh/sshd_config
@nudles
nudles / xceptionnet.py
Created June 4, 2020 02:56
xceptionet get/set params
class Block(layer.Layer):
def set_params(self, parameters):
for lyr in self.layers:
lyr.set_params(parameters)
def get_params(self):
params = {}
for lyr in self.layers:
params.update(lyr.get_params())
@nudles
nudles / readme.md
Last active June 3, 2020 12:08
Scalar Tensor
  • To capture changing scalar values, we need to store them into Tensors to be recorded by the graph.

  • If we store the value like other Tensors on gpu memory, then we need cudamemcpy to access the scalar value. However, this cudamemcpy may run in parallel with another operator that takes the scalar value as input.

  • For example, axpy takes scalar data types like float, axpy(float alpha, ...). If alpha is stored in a tensor, then we need to get the value from gpu memory and pass it to axpy.

    alpha = Tensor()
    axpy(alpha, ...) #python code
    
    axpy(Tensor alpha, ...)  # cpp code
@nudles
nudles / readme.md
Last active June 4, 2020 07:47
FAQ Bot

Updated at 3:46PM, June 4

We are going to implement this model using SINGA. https://github.com/jojonki/QA-LSTM Please ignore the text below currently.

Task

Create a question answering model for customer support.

The dataset

@nudles
nudles / sdsc.md
Last active May 22, 2020 09:50
Outline of SINGA Tutorial for SDSC
@nudles
nudles / layer.py
Last active May 31, 2020 05:23
New APIs of SINGA
class Layer:
def __init__(self,):
self.has_initialized = False
def get_params(self):
"""return the params of this layer and sublayers as a dict;
param name is: layername.param_name. e.g.,
self.W = Tensor(), self.b=Tensor()
name of W and b is like conv1.W and conv1.b
@nudles
nudles / settings.json
Last active August 9, 2019 00:49
Configuration of Visual Studio Code
{
"workbench.colorTheme": "Solarized Light",
"python.formatting.provider": "yapf",
"autoDocstring.docstringFormat": "google",
"cSpell.userWords": [
"Conda",
"Docstring",
"SINGA",
"autobuild",
"recommonmark",
import logging
# create logger
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
@nudles
nudles / agent.py
Last active February 1, 2018 05:33
xception-foodlg
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@nudles
nudles / alexnet-parallel.cc
Last active April 10, 2017 09:07
run alexnet over cifar10 in parallel with a GPU device and a CPU device. replace the original alexnet-parallel.cc in the example folder; compile singa with "cmake -DENABLE_TEST=ON -DUSE_CUDA=ON _DUSE_PYTHON=OFF ..""
/************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*