Skip to content

Instantly share code, notes, and snippets.

class NeuralNetwork(nn.Module):
def __init__(self, numChannels, classes):
# call the parent constructor
super(NeuralNetwork, self).__init__()
# initialize first set of CONV => RELU => POOL layers
self.conv1 = nn.Conv2d(
in_channels=numChannels, out_channels=20, kernel_size=(5, 5)
)
self.relu1 = nn.ReLU()
self.maxpool1 = nn.MaxPool2d(kernel_size=(2, 2), stride=(2, 2))
# Define model
class NeuralNetwork(nn.Module):
def __init__(self, input_size, output_size, hidden_dim, n_layers):
super(NeuralNetwork, self).__init__()
self.hidden_dim = hidden_dim
self.n_layers = n_layers
self.rnn = nn.RNN(input_size, hidden_dim, n_layers, batch_first=True)
self.fc = nn.Linear(hidden_dim, output_size)
import numpy as np
import pylab
def is_prime(n):
status = True
if n < 2:
status = False
else:
for i in range(2,n):
function mapStateToProps(state) {
return {
value: state.blackbox.value
}
}
function mapDispatchToPops(dispatch) {
return {
setLHS: () => null, // TBD
setRHS: () => null, // TBD
@srossross
srossross / maintain-state.js
Last active March 17, 2017 02:39
maintain-state.js
const BB_UPDATE_STATE = '@@blackbox.updateState';
const bbUpdateState = () => ({
type: BB_UPDATE_STATE
});
const serializeState = () => ({
value: blackbox.getResult()
});
@srossross
srossross / api.ts
Last active March 17, 2017 02:39
BlackBox API
// BlackBox API
// Constructor
blackbox = new BlackBox(element: Element)
// Methods
blackbox.setLeft(value: Number)
blackbox.setRight(value: Number)
blackbox.getResult(): Number
@srossross
srossross / .gitconfig
Last active February 14, 2017 22:34
My Environment Files
[alias]
ci = commit
co = checkout
st = status
ss = status -sb
ssb = submodule foreach 'git status -sb'
br = branch
bb = for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
bn = !git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' | tail -n 10
clean-branches = !git branch -d $(git branch --merged develop | grep -v 'develop')
In [14]: class Foo(Model):
name = StringType()
def __getattr__(self, attr):
print '__getattr__', attr
return self.__dict__['_initial'].get(attr, None)
def validate(self, partial=False, strict=False, **kwargs):
try:
super().validate(partial=partial, strict=strict, **kwargs)
except ModelValidationError as exc:
print(exc.messages)
from schematics.models import Model
from schematics.types import StringType, URLType
from schematics.transforms import import_loop
import warnings
class Foo(Model):
name = StringType()
import subprocess as sp
from binstar_build_client.worker.utils.timeout import Timeout
import time
import io
import os
class FakeBuildLog(object):
"""
This class should actually post to anaconda-server