Skip to content

Instantly share code, notes, and snippets.

Andrew AndrewBMartin

View GitHub Profile
@AndrewBMartin
AndrewBMartin / train.py
Last active Feb 28, 2019
Example training function with tensorboardcolab
View train.py
def train(model, train_loader, device, optimizer, log_interval, epoch, globaliter, tb):
"""
Example training function for PyTorch recording to tensorboardcolab.
"""
model.train()
for batch_idx, (data, target) in enumerate(train_loader):
globaliter += 1
data, target = data.to(device), target.to(device)
@AndrewBMartin
AndrewBMartin / train.py
Last active Feb 28, 2019
Example training function with tensorboard
View train.py
def train(model, train_loader, device, optimizer, log_interval, epoch, globaliter):
"""
Example training function for PyTorch recording to TensorBoard.
"""
model.train()
for batch_idx, (data, target) in enumerate(train_loader):
globaliter += 1
data, target = data.to(device), target.to(device)
@AndrewBMartin
AndrewBMartin / gurobi.log
Created Nov 9, 2015
Gurobi Log - Barrier reset behaviour
View gurobi.log
Optimize a model with 889545 rows, 7495464 columns and 230380625 nonzeros
Coefficient statistics:
Matrix range [1e-03, 7e+02]
Objective range [8e-01, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [5e-01, 6e+06]
Concurrent LP optimizer: dual simplex and barrier
Showing barrier log only...
@AndrewBMartin
AndrewBMartin / Lp_wrapper
Created May 27, 2014
Python wrapper to store an lp file as a model object
View Lp_wrapper
""""
Try to create model, variable and constraint objects.
Try to read the lp into a model object faster.
"""
import os
from profilehooks import profile, timecall
class Model(object):
@AndrewBMartin
AndrewBMartin / main.py
Last active Dec 29, 2015
Hacker School Application: A routine that simulates the growth and yields of a list of timber stands over a 30 period planning horizon, and writes the results to 4 output files. These output files are used to supply parameter values for an AMPL generated Linear Programming model.
View main.py
import os
import csv
import pres_builder as pb
# Indicates whether prescription set A or B
# is to be generated, in the case a prescription
# set will be generated.
global model_type
model_type = 'B'
@AndrewBMartin
AndrewBMartin / application_admin.py
Created Nov 28, 2013
model.py and application_admin.py for camelot Videostore Tutorial
View application_admin.py
from camelot.view.art import Icon
from camelot.admin.application_admin import ApplicationAdmin
from camelot.admin.section import Section
from camelot.core.utils import ugettext_lazy as _
class MyApplicationAdmin(ApplicationAdmin):
name = 'Videostore'
application_url = 'http://www.python-camelot.com'
You can’t perform that action at this time.