Skip to content

Instantly share code, notes, and snippets.

@Denbergvanthijs
Denbergvanthijs / game_of_life_keras.py
Last active April 13, 2024 12:44
Conway's Game of Life using a neural network with Keras and Tensorflow in Python
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from matplotlib.animation import FuncAnimation
from tensorflow.keras.layers import Conv2D, InputLayer, Layer
from tensorflow.keras.models import Sequential
size = 128
n_frames = 240
full_size = (1, size, size, 1)
import types
class ClassMethod(object):
def __init__(self, func):
self.__func__ = func
def __get__(self, obj, objtype=None):
return types.MethodType(self.__func__, objtype or type(obj), type)
@carljm
carljm / staticmethod.py
Created June 27, 2012 14:55
pure Python implementation of the staticmethod decorator
class StaticMethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, cls):
return self.func
def staticmethod(func):