Skip to content

Instantly share code, notes, and snippets.

View smcantab's full-sized avatar
🎯
Focusing

Stefano Martiniani smcantab

🎯
Focusing
View GitHub Profile
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
import zlib
def generate_const_image_bw(nx, ny):
im = np.zeros((nx, ny), dtype='uint8')
return im
def generate_checkerboard_image_bw(nx, ny):
#pele and PyCG_DESCENT need to be installed and added to the pythonpath
import numpy as np
from pele.potentials import BasePotential
from PyCG_DESCENT import CGDescent
class squareFunc(BasePotential):
# this is the only method that you actually need to implement
def getEnergy(self, x):
val = x[0]**2 + x[1]**2
return val
from __future__ import division
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def select_device_simple(dev="cpu"):
if dev.lower() == "cpu":
return "/cpu:0"
elif dev.lower() == 'gpu':
return "/gpu:0"