我现在正在用hyperopt训练很多神经网络。有时能完美运行通过,有时不能,我不明白为什么。它指的是验证数据,但那总是一样的。我还没有使用任何k-fold CV。字典设置中存储的参数'Monitor','Patience','MinDelta','Epochs'和'BatchSize'也保持不变。如你所见,shuffle也被设置为False。我刚刚试着用同样的超参数手动训练网络,结果成功了。GPU VRAM应该是足够的,因为我训练更大的网络没有问题(更多的神经元,更高的批次大小)。有人有什么建议或猜测是什么原因会导致这个错误吗?
下面是一些相关的代码片段。
from tensorflow.keras.callbacks import EarlyStopping
early_stopping = EarlyStopping(monitor=setup['Monitor'], patience=setup['Patience'],mode='min',
restore_best_weights=True,min_delta=setup['MinDelta'])
history = autoencoder.fit(trainx, trainy, epochs = setup['Epochs'], batch_size = setup['BatchSize'],
validation_data=(valx,valy),callbacks=[early_stopping],verbose=0,shuffle=False)
使用了上一次显示错误的参数。
{'AFunction': 'relu', 'BatchNorm': False, 'BatchSize': 56, 'Bottleneck': 16, 'Dataset': 'ml100k',
'Date': '2020-03-14__22_46_30', 'DecNeurons': 480, 'Decay': 0.0006340241989020302,
'Dropout': 0.0003539460040469268, 'EncNeurons': 256, 'Epochs': 100, 'ID': 3,
'LR': 0.3869023252696237, 'Layers': 4, 'Metric': 'RMSE', 'MinDelta': 0.01,
'Monitor': 'val_root_mean_squared_error', 'MP': True, 'Noise': 0.02, 'Normalize': False,
'Optimizer': 'adam', 'Patience': 25, 'RDigits': 5, 'Split': 'Movie', 'WeightInit': 0,
'Neurons': [480, 408, 328, 256, 16, 256, 328, 408, 480], 'NeuronSum': 2960,
'Loss': <function MMSE at 0x000001DED8DD60D0>, 'IO': 943}
我得到了以下错误。
File "<ipython-input-3-3d2f96200fbe>", line 26, in <module>
best = fmin(fn=ae,space=parameterspace,algo=algo,trials = bayes_trials,max_evals=5000)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\fmin.py", line 482, in fmin
show_progressbar=show_progressbar,
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\base.py", line 686, in fmin
show_progressbar=show_progressbar,
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\fmin.py", line 509, in fmin
rval.exhaust()
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\fmin.py", line 330, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.asynchronous)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\fmin.py", line 286, in run
self.serial_evaluate()
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\fmin.py", line 165, in serial_evaluate
result = self.domain.evaluate(spec, ctrl)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\hyperopt\base.py", line 894, in evaluate
rval = self.fn(pyll_rval)
File "<ipython-input-1-5d0cd446e015>", line 229, in ae
validation_data=(valx,valy),callbacks=[early_stopping],verbose=0,shuffle=False)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 728, in fit
use_multiprocessing=use_multiprocessing)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 372, in fit
prefix='val_')
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\contextlib.py", line 88, in __exit__
next(self.gen)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 685, in on_epoch
self.callbacks.on_epoch_end(epoch, epoch_logs)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\callbacks.py", line 298, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\callbacks.py", line 1238, in on_epoch_end
self.model.set_weights(self.best_weights)
File "C:\Users\Admin\Anaconda3\envs\tf2\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 1322, in set_weights
if len(params) != len(weights):
TypeError: object of type 'NoneType' has no len()
使用了环境。
(tf2) C:\Users\Admin>conda list
# packages in environment at C:\Users\Admin\Anaconda3\envs\tf2:
#
# Name Version Build Channel
_tflow_select 2.1.0 gpu
absl-py 0.8.1 py36_0
alabaster 0.7.12 py36_0
alembic 1.3.2 py_0 conda-forge
appdirs 1.4.3 py_1 conda-forge
asn1crypto 1.3.0 py36_0
astor 0.8.0 py36_0
astroid 2.3.3 py36_0
attrs 19.3.0 py_0
babel 2.8.0 py_0
backcall 0.1.0 py36_0
backports 1.0 py_2 conda-forge
bayesian-optimization 1.0.1 py_0 conda-forge
blas 1.0 mkl
bleach 3.1.0 py36_0
ca-certificates 2020.1.1 0 anaconda
certifi 2019.11.28 py36_0 anaconda
cffi 1.13.2 py36h7a1dbc1_0
chardet 3.0.4 py36_1003
click 7.0 py_0 conda-forge
cloudpickle 1.2.2 py_0
colorama 0.4.3 py_0
configparser 3.7.3 py36_1 conda-forge
cryptography 2.8 py36h7a1dbc1_0
cudatoolkit 10.0.130 0
cudnn 7.6.5 cuda10.0_0
cycler 0.10.0 py36h009560c_0
databricks-cli 0.9.1 py_0 conda-forge
decorator 4.4.1 py_0
defusedxml 0.6.0 py_0
docker-py 4.1.0 py36_0 conda-forge
docker-pycreds 0.4.0 py_0 conda-forge
docutils 0.15.2 py36_0
entrypoints 0.3 py36_0
flask 1.1.1 py_1 conda-forge
floweaver 2.0.0a5 py_0 conda-forge
freetype 2.9.1 ha9979f8_1
future 0.18.2 pypi_0 pypi
gast 0.2.2 py36_0
gitdb2 2.0.6 py_0 conda-forge
gitpython 3.0.5 py_0 conda-forge
google-pasta 0.1.8 py_0
gorilla 0.3.0 py_0 conda-forge
grpcio 1.16.1 py36h351948d_1
h5py 2.9.0 py36h5e291fa_0
hdf5 1.10.4 h7ebc959_0
hyperopt 0.2.3 pypi_0 pypi
icc_rt 2019.0.0 h0cc432a_1
icu 58.2 ha66f8fd_1
idna 2.8 py36_0
imagesize 1.2.0 py_0
importlib_metadata 1.3.0 py36_0
intel-openmp 2019.4 245
ipykernel 5.1.3 py36h39e3cac_1
ipython 7.11.1 py36h39e3cac_0
ipython_genutils 0.2.0 py36_0
ipywidgets 7.5.1 py_0
isort 4.3.21 py36_0
itsdangerous 1.1.0 py_0 conda-forge
jedi 0.15.2 py36_0
jinja2 2.10.3 py_0
joblib 0.14.1 py_0
jpeg 9b hb83a4c4_2
jsonschema 3.2.0 py36_0
jupyter 1.0.0 py36_7
jupyter_client 5.3.4 py36_0
jupyter_console 6.0.0 py36_0
jupyter_core 4.6.1 py36_0
keras 2.3.1 py36h21ff451_0 conda-forge
keras-applications 1.0.8 py_0
keras-preprocessing 1.1.0 py_1
keyring 20.0.0 py36_0
kiwisolver 1.1.0 py36ha925a31_0
lazy-object-proxy 1.4.3 py36he774522_0
libgpuarray 0.7.6 hfa6e2cd_1003 conda-forge
libpng 1.6.37 h2a8f88b_0
libprotobuf 3.11.2 h7bd577a_0
libsodium 1.0.16 h9d3ae62_0
m2w64-gcc-libgfortran 5.3.0 6
m2w64-gcc-libs 5.3.0 7
m2w64-gcc-libs-core 5.3.0 7
m2w64-gmp 6.1.0 2
m2w64-libwinpthread-git 5.0.0.4634.697f757 2
mako 1.1.0 py_0 conda-forge
markdown 3.1.1 py36_0
markupsafe 1.1.1 py36he774522_0
matplotlib 3.1.1 py36hc8f65d3_0
mccabe 0.6.1 py36_1
mistune 0.8.4 py36he774522_0
mkl 2019.4 245
mkl-service 2.3.0 py36hb782905_0
mkl_fft 1.0.15 py36h14836fe_0
mkl_random 1.1.0 py36h675688f_0
mlflow 1.5.0 py36_1 conda-forge
more-itertools 8.0.2 py_0
msys2-conda-epoch 20160418 1
nbconvert 5.6.1 py36_0
nbformat 4.4.0 py36_0
networkx 2.2 pypi_0 pypi
notebook 6.0.2 py36_0
numpy 1.17.4 py36h4320e6b_0
numpy-base 1.17.4 py36hc3f5095_0
numpydoc 0.9.2 py_0
openssl 1.1.1 he774522_0 anaconda
opt_einsum 3.1.0 py_0
packaging 20.0 py_0
palettable 3.3.0 py_0 conda-forge
pandas 0.25.3 py36ha925a31_0
pandoc 2.2.3.2 0
pandocfilters 1.4.2 py36_1
parso 0.5.2 py_0
pickleshare 0.7.5 py36_0
pip 19.3.1 py36_0
plotly 3.10.0 pypi_0 pypi
prometheus_client 0.7.1 py_0
prometheus_flask_exporter 0.12.1 py_0 conda-forge
prompt_toolkit 2.0.10 py_0
protobuf 3.11.2 py36h33f27b4_0
psutil 5.6.7 py36he774522_0
pycodestyle 2.5.0 py36_0
pycparser 2.19 py36_0
pyflakes 2.1.1 py36_0
pygments 2.5.2 py_0
pygpu 0.7.6 py36hc8d92b1_1000 conda-forge
pylint 2.4.4 py36_0
pyopenssl 19.1.0 py36_0
pyparsing 2.4.6 py_0
pyqt 5.9.2 py36h6538335_2
pyreadline 2.1 py36_1
pyrsistent 0.15.6 py36he774522_0
pysocks 1.7.1 py36_0
python 3.6.10 h9f7ef89_0
python-dateutil 2.8.1 py_0
python-editor 1.0.4 py_0 conda-forge
pytz 2019.3 py_0
pywin32 227 py36he774522_1
pywin32-ctypes 0.2.0 py36_0
pywinpty 0.5.7 py36_0
pyyaml 5.3 py36hfa6e2cd_0 conda-forge
pyzmq 18.1.0 py36ha925a31_0
qt 5.9.7 vc14h73c81de_0
qtawesome 0.6.0 py_0
qtconsole 4.6.0 py_1
qtpy 1.9.0 py_0
querystring_parser 1.2.4 py_0 conda-forge
requests 2.22.0 py36_1
retrying 1.3.3 py36_2
rope 0.14.0 py_0
scikit-learn 0.22.1 py36h6288b17_0
scipy 1.3.2 py36h29ff71c_0
seaborn 0.10.0 py_0 anaconda
send2trash 1.5.0 py36_0
setuptools 44.0.0 py36_0
simplejson 3.17.0 py36hfa6e2cd_0 conda-forge
sip 4.19.8 py36h6538335_0
six 1.13.0 py36_0
smmap2 2.0.5 py_0 conda-forge
snowballstemmer 2.0.0 py_0
sphinx 2.3.1 py_0
sphinxcontrib-applehelp 1.0.1 py_0
sphinxcontrib-devhelp 1.0.1 py_0
sphinxcontrib-htmlhelp 1.0.2 py_0
sphinxcontrib-jsmath 1.0.1 py_0
sphinxcontrib-qthelp 1.0.2 py_0
sphinxcontrib-serializinghtml 1.1.3 py_0
spyder 3.3.6 py36_0
spyder-kernels 0.5.2 py36_0
sqlalchemy 1.3.12 py36hfa6e2cd_0 conda-forge
sqlite 3.30.1 he774522_0
sqlparse 0.3.0 py_0 conda-forge
tabulate 0.8.6 py_0 conda-forge
tensorboard 2.0.0 pyhb38c66f_1
tensorflow 2.0.0 gpu_py36hfdd5754_0
tensorflow-base 2.0.0 gpu_py36h390e234_0
tensorflow-estimator 2.0.0 pyh2649769_0
tensorflow-gpu 2.0.0 h0d30ee6_0
termcolor 1.1.0 py36_1
terminado 0.8.3 py36_0
testpath 0.4.4 py_0
theano 1.0.4 py36h6538335_1001 conda-forge
tornado 6.0.3 py36he774522_0
tqdm 4.43.0 pypi_0 pypi
traitlets 4.3.3 py36_0
typed-ast 1.4.0 py36he774522_0
urllib3 1.25.7 py36_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.16.27012 hf0eaf9b_1
vs2015_win-64 14.0.25420 h55c1224_11
waitress 1.4.1 py_0 conda-forge
wcwidth 0.1.7 py36_0
webencodings 0.5.1 py36_1
websocket-client 0.57.0 py36_0 conda-forge
werkzeug 0.16.0 py_0
wheel 0.33.6 py36_0
widgetsnbextension 3.5.1 py36_0
win_inet_pton 1.1.0 py36_0
wincertstore 0.2 py36h7fe50ca_0
winpty 0.4.3 4
wrapt 1.11.2 py36he774522_0
yaml 0.2.2 hfa6e2cd_1 conda-forge
zeromq 4.3.1 h33f27b4_3
zipp 0.6.0 py_0
zlib 1.2.11 h62dcd97_3