示例#1
0
 def test_many_to_many_nested(self):
     hc.reset()
     hc.set('x', [1, 2, 3])
     hc.set('y', [1, 2, 3])
     hc.set('z', [1, 2, 3])
     self.assertEqual(hc.count_configs(), 27)
     self.assertEqual(hc.configs(1, serial=True,offset=0,create_uuid=False), [{'x':1, 'y': 1, 'z': 1}])
示例#2
0
 def test_only_permutation(self):
     hc.reset()
     for i in range(20):
       hc.set('a'+str(i), [1, 2, 3])
     self.assertEqual(hc.count_configs(), 3**20)
     self.assertEqual(hc.configs(1, serial=True, offset=0)[0]['a1'], 1)
     self.assertEqual(hc.configs(1, serial=True, offset=0)[0]['a2'], 1)
示例#3
0
 def test_many_to_many_nested(self):
     hc.reset()
     hc.set('x', [1, 2, 3])
     hc.set('y', [1, 2, 3])
     hc.set('z', [1, 2, 3])
     self.assertEqual(hc.count_configs(), 27)
     self.assertEqual(hc.configs(1, serial=True,offset=0,create_uuid=False), [{'x':1, 'y': 1, 'z': 1}])
示例#4
0
 def test_only_permutation(self):
     hc.reset()
     for i in range(20):
         hc.set('a' + str(i), [1, 2, 3])
     self.assertEqual(hc.count_configs(), 3**20)
     self.assertEqual(hc.configs(1, serial=True, offset=0)[0]['a1'], 1)
     self.assertEqual(hc.configs(1, serial=True, offset=0)[0]['a2'], 1)
示例#5
0
 def test_many_to_many(self):
     hc.reset()
     hc.set('x', [1,2,3])
     hc.set('y', [1, 2, 3])
     self.assertEqual(hc.count_configs(), 9)
     configs = hc.configs(3, serial=True,create_uuid=False,offset=0)
     self.assertNotEqual(configs[0], configs[1])
     self.assertNotEqual(configs[1], configs[2])
示例#6
0
 def test_many_to_many(self):
     hc.reset()
     hc.set('x', [1, 2, 3])
     hc.set('y', [1, 2, 3])
     self.assertEqual(hc.count_configs(), 9)
     configs = hc.configs(3, serial=True, create_uuid=False, offset=0)
     self.assertNotEqual(configs[0], configs[1])
     self.assertNotEqual(configs[1], configs[2])
示例#7
0
 def test_one_permute(self):
     hc.reset()
     hc.set('x', 1)
     hc.set('y', [1])
     self.assertEqual(hc.count_configs(), 1)
     self.assertEqual(
         hc.configs(1, serial=True, offset=0, create_uuid=False), [{
             'x': 1,
             'y': 1
         }])
示例#8
0
    results =  {
        'difficulty':float(difficulty),
        'ranking':float(ranking),
        'g_loss':float(g_loss),
        'd_fake':float(d_fake),
        'd_real':float(d_real),
        'e_loss':float(e_loss)
    }
    print("Recording ", results)
    #hc.io.record(config, results)





print("Generating configs with hyper search space of ", hc.count_configs())

j=0
k=0

def get_function(name):
    if not isinstance(name, str):
        return name
    print('name', name);
    if(name == "function:tensorflow.python.ops.gen_nn_ops.relu"):
        return tf.nn.relu
    if(name == "function:tensorflow.python.ops.nn_ops.relu"):
        return tf.nn.relu
    if(name == "function:tensorflow.python.ops.gen_nn_ops.relu6"):
        return tf.nn.relu6
    if(name == "function:tensorflow.python.ops.nn_ops.relu6"):
示例#9
0
    plt.tight_layout()
    img = "samples/reconstruction.png"
    plt.savefig(img)
    hc.io.sample(config, [{"label": "Reconstruction", "image": img}])

hc.permute.set("learning_rate", list(np.linspace(0.0001, 0.003, num=10, dtype=np.float32)))
hc.permute.set("n_hidden_recog_1", list(np.linspace(100, 1000, num=10, dtype=np.int32)))
hc.permute.set("n_hidden_recog_2", list(np.linspace(100, 1000, num=10, dtype=np.int32)))
hc.permute.set("n_hidden_gener_1", list(np.linspace(100, 1000, num=10, dtype=np.int32)))
hc.permute.set("n_hidden_gener_2", list(np.linspace(100, 1000, num=10, dtype=np.int32)))

hc.set("n_input", 784) # MNIST data input (img shape: 28*28)
hc.permute.set("n_z", [1,2,4,8,16,32,64,128]) # dimensionality of latent space
hc.set('batch_size', 100)
hc.permute.set("transfer_fct", [tf.tanh, tf.nn.elu, tf.nn.relu, tf.nn.relu6, tf.nn.softplus, tf.nn.softsign]);

hc.set("epochs", 10)

print("hypersearch space", hc.count_configs())
for config in hc.configs(10000):
    print("Config", config)
    vae = VariationalAutoencoder(config, 
                                 learning_rate=config['learning_rate'],
                                 transfer_fct=config['transfer_fct'])
    cost = 1000
    for i in range(config['epochs']):
        cost = train(config, vae, training_epochs=1)
        sample(config, vae)
    hc.io.measure(config, {"rank": cost})
    visualize(config, vae)
示例#10
0
 def test_one_permute(self):
     hc.reset()
     hc.set('x', 1)
     hc.set('y', [1])
     self.assertEqual(hc.count_configs(), 1)
     self.assertEqual(hc.configs(1, serial=True,offset=0,create_uuid=False), [{'x':1, 'y': 1}])
示例#11
0
 def test_store_size(self):
     hc.reset()
     hc.set('x', [1,2])
     self.assertEqual(hc.count_configs(), 2)
示例#12
0
 def test_reset(self):
     hc.reset()
     self.assertEqual(hc.configs(), [])
     self.assertEqual(hc.count_configs(), 1)
示例#13
0
 def test_store_size(self):
     hc.reset()
     hc.set('x', [1,2])
     self.assertEqual(hc.count_configs(), 2)
示例#14
0
 def test_reset(self):
     hc.reset()
     self.assertEqual(hc.configs(), [])
     self.assertEqual(hc.count_configs(), 1)
示例#15
0
def test_config(sess, config):
    batch_size = config["batch_size"]
    n_samples = mnist.test.num_examples
    total_batch = int(n_samples / batch_size)
    accuracies = []
    costs = []
    for i in range(total_batch):
        x, y = mnist.test.next_batch(batch_size)
        x=np.reshape(x, [batch_size, X_DIMS[0], X_DIMS[1], 1])
        accuracy, cost = test(sess, config, x, y)
        accuracies.append(accuracy)
        costs.append(cost)
    return accuracies, costs


print("Searching randomly with %d possible configurations." % hc.count_configs())
for i in range(100):
    config = hc.random_config()
    print("Testing configuration", config)
    sess = tf.Session()
    graph = create(config)
    init = tf.initialize_all_variables()
    sess.run(init)
    for i in range(10):
        epoch(sess, config)
    accuracies, costs = test_config(sess, config)
    accuracy, cost = np.mean(accuracies), np.mean(costs)
    results =  {
        'accuracy':accuracy,
        'cost':cost
        }
示例#16
0
    ranking = g_loss * (1.0 - difficulty)

    ranking = e_loss
    results = {
        'difficulty': float(difficulty),
        'ranking': float(ranking),
        'g_loss': float(g_loss),
        'd_fake': float(d_fake),
        'd_real': float(d_real),
        'e_loss': float(e_loss)
    }
    print("Recording ", results)
    #hc.io.record(config, results)


print("Generating configs with hyper search space of ", hc.count_configs())

j = 0
k = 0


def get_function(name):
    if not isinstance(name, str):
        return name
    print('name', name)
    if (name == "function:tensorflow.python.ops.gen_nn_ops.relu"):
        return tf.nn.relu
    if (name == "function:tensorflow.python.ops.nn_ops.relu"):
        return tf.nn.relu
    if (name == "function:tensorflow.python.ops.gen_nn_ops.relu6"):
        return tf.nn.relu6