Example #1
0
  def run(seed=1, ticks=100):
    print('#', seed)
    rseed(seed)
    w = o(now=0)
    while w.now < ticks:
      alive = False
      for machine in shuffle(Machine.Factory):
        if not machine.here.stop():
          alive = True
          w.now += 1
          machine.step(w)
          Machine.report(machine.name)
          break
      if not alive: break

    return w
Example #2
0
    train_y_valid = data["y_valid"]
    train_y_not_valid = data["y_not_valid"]
    max_length = data["max_length"][0]

    #split data, make sure test data contains all types of samples (valid and not valid ones)
    train_x_valid, test_x_valid, train_y_valid, test_y_valid = split_dataset(
        train_x_valid, train_y_valid, 5)
    train_x_not_valid, test_x_not_valid, train_y_not_valid, test_y_not_valid = split_dataset(
        train_x_not_valid, train_y_not_valid, 5)

    train_x = numpy.concatenate((train_x_valid, train_x_not_valid))
    train_y = numpy.concatenate((train_y_valid, train_y_not_valid))
    test_x = numpy.concatenate((test_x_valid, test_x_not_valid))
    test_y = numpy.concatenate((test_y_valid, test_y_not_valid))

    train_x, train_y = shuffle(train_x, train_y)
    test_x, test_y = shuffle(test_x, test_y)

    #convert y to one-hot encoding
    #train_y = to_categorical(train_y, 2)
    #test_y = to_categorical(test_y, 2)

    train_x = train_x.astype("float32")
    test_x = test_x.astype("float32")

    #train_x /= 255
    #test_x /= 255

    train_x = numpy.expand_dims(train_x, axis=2)
    test_x = numpy.expand_dims(test_x, axis=2)
Example #3
0
 def next(i, w):
   for tran in shuffle(i.out):
     if tran.gaurd(w, tran):
       return tran.there
   return i