Instantly share code, notes, and snippets.

View gpu_info.py
from subprocess import Popen, PIPE
from xml.etree.ElementTree import fromstring
def main():
p = Popen(['nvidia-smi', '-q', '-x'], stdout=PIPE)
outs, errors = p.communicate()
xml = fromstring(outs)
num_gpus = int(xml.getiterator('attached_gpus')[0].text)
results = []
View reptile.py
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
mode = 'maml'
seed = 0
plot = True
innerstepsize = 0.02 # stepsize in inner SGD
innerepochs = 1 # number of epochs of each inner SGD
outerstepsize0 = 0.1 if mode == 'reptile' else 0.001 # stepsize of outer optimization, i.e., meta-optimization