This repository was archived by the owner on Feb 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 554
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
Error in plot_objective() and plot_evaluations() #576
Copy link
Copy link
Closed
Description
I am using skopt with Keras and TensorFlow to tune the hyper-parameters of a Neural Network. Everything works fine except for the plots.
I have tried installing the most recent development-version of skopt from GitHub today.
These are my parameter-dimensions:
dim_learning_rate = Real(low=1e-6, high=1e-2, prior='log-uniform')
dim_num_dense_layers = Integer(low=1, high=5)
dim_num_dense_nodes = Integer(low=5, high=512)
dim_activation = Categorical(categories=['relu', 'sigmoid'])
Here is the error from calling plot_evaluations():
plot_evaluations(search_results)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-40-bf80cc7b140c> in <module>()
----> 1 plot_evaluations(search_results)
~/development/scikit-optimize/skopt/plots.py in plot_evaluations(result, bins, dimensions)
402 bins_ = bins
403 ax[i, i].hist(samples[:, j], bins=bins_,
--> 404 range=space.dimensions[j].bounds)
405
406 # lower triangle
~/anaconda3/envs/tf-test/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1890 warnings.warn(msg % (label_namer, func.__name__),
1891 RuntimeWarning, stacklevel=2)
-> 1892 return func(ax, *args, **kwargs)
1893 pre_doc = inner.__doc__
1894 if pre_doc is None:
~/anaconda3/envs/tf-test/lib/python3.6/site-packages/matplotlib/axes/_axes.py in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
6190 # this will automatically overwrite bins,
6191 # so that each histogram uses the same bins
-> 6192 m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
6193 m = m.astype(float) # causes problems later if it's an int
6194 if mlast is None:
~/anaconda3/envs/tf-test/lib/python3.6/site-packages/numpy/lib/function_base.py in histogram(a, bins, range, normed, weights, density)
794 for i in arange(0, len(a), BLOCK):
795 sa = sort(a[i:i+BLOCK])
--> 796 n += np.r_[sa.searchsorted(bins[:-1], 'left'),
797 sa.searchsorted(bins[-1], 'right')]
798 else:
TypeError: Cannot cast array data from dtype('float64') to dtype('<U32') according to the rule 'safe'
This is the image it outputs:
I thought the problem was maybe because of the Categorical variable so I tried omitting it by only using the first 3 dimensions:
plot_evaluations(search_results, dimensions=['X_0', 'X_1', 'X_2'])
But it gives the exact same error.
Here is the result for plot_objective():
plot_objective(search_results, dimensions=['X_0', 'X_1', 'X_2'])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-43-f5cf47c2e09c> in <module>()
----> 1 plot_objective(search_results, dimensions=['X_0', 'X_1', 'X_2'])
~/development/scikit-optimize/skopt/plots.py in plot_objective(result, levels, n_points, n_samples, size, zscale, dimensions)
341 xi, yi, zi = partial_dependence(space, result.models[-1],
342 i, j,
--> 343 rvs_transformed, n_points)
344 ax[i, j].contourf(xi, yi, zi, levels,
345 locator=locator, cmap='viridis_r')
~/development/scikit-optimize/skopt/plots.py in partial_dependence(space, model, i, j, sample_points, n_samples, n_points)
243
244 bounds = space.dimensions[i].bounds
--> 245 yi = np.linspace(bounds[0], bounds[1], n_points)
246 yi_transformed = space.dimensions[i].transform(yi)
247
~/anaconda3/envs/tf-test/lib/python3.6/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype)
106 # Convert float/complex array scalars to float, gh-3504
107 # and make sure one can use variables that have an __array_interface__, gh-6634
--> 108 start = asanyarray(start) * 1.0
109 stop = asanyarray(stop) * 1.0
110
TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')
This is the image it outputs:
(This was discussed briefly in thread #570 but it appears that the dev-version of skopt does not solve the problem, so I was asked to open a new thread so it wouldn't be forgotten.)
Metadata
Metadata
Assignees
Labels
No labels

