Skip to content

Instantly share code, notes, and snippets.

View matthewroche's full-sized avatar

Matthew Roche matthewroche

View GitHub Profile
@matthewroche
matthewroche / intervals_oauth_lambda.py
Created April 17, 2022 06:59
Python OAuth flow for Intervals.icu Lambda
import os
from base64 import b64decode
# Handles a call from the intervals.icu OauthAPI, requests the auth token and returns this in a redirect URL
def lambda_handler(event, context):
# Generic error object to handle errors
def createErrorObject(reason):
return {
'statusCode': 301,
@matthewroche
matthewroche / gist:a0abcb49c6c7ad123ad14e2dfa687d99
Created March 12, 2018 20:51
Pooling Linear Classifier inc Softmax
# Create custom classifier
class PoolingLinearClassifierSoftmax(nn.Module):
def __init__(self, layers, drops):
super().__init__()
self.layers = nn.ModuleList([
LinearBlock(layers[i], layers[i + 1], drops[i]) for i in range(len(layers) - 1)])
def pool(self, x, bs, is_max):
f = F.adaptive_max_pool1d if is_max else F.adaptive_avg_pool1d
return f(x.permute(1,2,0), (1,)).view(bs,-1)