Ejemplo n.º 1
0
def predict_multiplier (x, y):
  """load a model from "mul.hdf5" and predict the response
  for inputs (x, y) i.e., multiply them together and get the answer"""
  mdl = Arithmodel ("mul", '*')
  print (mdl.predict (x, y))
Ejemplo n.º 2
0
def train_adder ():
  """train a network to learn addition"""
  mdl = Arithmodel ("add", '+')
  mdl.train (lambda x, y : x+y)
Ejemplo n.º 3
0
def predict_adder (x, y):
  """load a model from "add.hdf5" and predict the response
  for inputs (x, y) i.e., add them together and get the answer"""
  mdl = Arithmodel ("add", '+')
  print (mdl.predict (x, y))
Ejemplo n.º 4
0
def train_division ():
  """train a network to learn division"""
  mdl = Arithmodel ("div", '/')
  mdl.train (lambda x, y : x/y)
Ejemplo n.º 5
0
def train_modulo ():
  """train a network to learn modulus"""
  mdl = Arithmodel ("mod", '+')
  mdl.train (lambda x, y : x%y)
Ejemplo n.º 6
0
def train_subtractor ():
  """train a network to learn subtraction"""
  mdl = Arithmodel ("sub", '-')
  mdl.train (lambda x, y : x-y)
Ejemplo n.º 7
0
def train_multiplier ():
  """train a network to learn multiplication"""
  mdl = Arithmodel ("mul", 'x')
  mdl.train (lambda x, y : x*y)