maxim5 / hyper-engine

Python library for Bayesian hyper-parameters optimization
https://pypi.python.org/pypi/hyperengine
Apache License 2.0
86 stars 22 forks source link

XA and XB must have the same number of columns (i.e. feature dimension.) #16

Closed dyj0215 closed 4 years ago

dyj0215 commented 4 years ago

hello,

i am trying to implement your example with 2_1_cnn_mnist.py. and i want to add some layers.

like this: layer = conv_layer(x, params.conv[0]) layer = conv_layer(layer, params.conv[1]) layer = conv_layer(layer, params.conv[2]) layer = dense_layer(layer, params.dense) logits = tf.layers.dense(inputs=layer, units=10)

conv = [

Layer 1

hype.spec.new(
  filter_num = hype.spec.choice([32]),
  filter_size = [hype.spec.choice([5])] * 2,
  activation = hype.spec.choice(ACTIVATIONS.keys()),
  batch_norm = hype.spec.random_bool(),
  dropout = hype.spec.uniform(0.0, 0.0),
),
# Layer 2
hype.spec.new(
  filter_num = hype.spec.choice([32]),
  filter_size = [hype.spec.choice([5])] * 2,
  activation = hype.spec.choice(ACTIVATIONS.keys()),
  batch_norm = hype.spec.random_bool(),
  dropout = hype.spec.uniform(0.0, 0.0),
),
# Layer 3
hype.spec.new(
  filter_num = hype.spec.choice([64]),
  filter_size = [hype.spec.choice([5])] * 2,
  activation = hype.spec.choice(ACTIVATIONS.keys()),
  batch_norm = hype.spec.random_bool(),
  dropout = hype.spec.uniform(0.0, 0.0),
),

]

i just add one layer and one params.con[]

so i got this issue: Traceback (most recent call last): File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/examples/2_1_cnn_mnist_try.py", line 118, in tuner.tune() File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/model/hyper_tuner.py", line 45, in tune point = self._strategy.next_proposal() File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/bayesian/strategy.py", line 150, in next_proposal return self._maximizer.compute_max_point() File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/bayesian/maximizer.py", line 41, in compute_max_point values = self._utility.compute_values(batch) File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/bayesian/utility.py", line 132, in compute_values mu, sigma = self.mean_and_std(batch) File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/bayesian/utility.py", line 64, in mean_and_std k_star = np.swapaxes(self.kernel.compute(self.points, batch), 0, 1) File "/Users/dongyijie/Downloads/hyper-engine/hyperengine/bayesian/kernel.py", line 57, in compute dist = cdist(batch_x, batch_y, **self._params) File "/Users/dongyijie/Downloads/hyper-engine/venv/lib/python3.7/site-packages/scipy/spatial/distance.py", line 2721, in cdist raise ValueError('XA and XB must have the same number of columns ' ValueError: XA and XB must have the same number of columns (i.e. feature dimension.)

so how can i fix it? thank you so much.

maxim5 commented 4 years ago

I think here's what happened: you let the example run for some time, then updated the spec and started it again. By default, it loads the state from disk and continues from there, but it can't do that if the dimensionality changed.

So either remove the state on disk or change the file name to start a brand new session.