Unfortunately, I stacked with such error while running the script in Jupyter Notebook:
def data():
'''
Data providing function:
This function is separated from model() so that hyperopt
won't reload data for each evaluation run.
'''
# Split uncentered data
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(dataset.T[1:,:], data['DATAEOI'].values, test_size=0.2, random_state=42)
# reshape from [samples, timesteps] into [samples, subsequences, timesteps, features]
samples = 1
subsequences = 1
X_train = X_train.reshape((X_train.shape[0], 1, X_train.shape[1], 1))
X_test = X_test.reshape((X_test.shape[0], 1, X_test.shape[1], 1))
y_train = y_train.reshape(y_train.shape[0], 1)
y_test = y_test.reshape(y_test.shape[0], 1)
return X_train, y_train, X_test, y_test
def model(X_train, y_train, X_test, y_test):
'''
Model providing function:
Create Keras model with double curly brackets dropped-in as needed.
Return value has to be a valid python dictionary with two customary keys:
- loss: Specify a numeric evaluation metric to be minimized
- status: Just use STATUS_OK and see hyperopt documentation if not feasible
The last one is optional, though recommended, namely:
- model: specify the model just created so that we can later use it again.
'''
# define model
model = Sequential()
model.add(TimeDistributed(Conv1D(filters={{choice([256, 512])}},
kernel_size={{choice([5, 3])}},
activation='elu',
padding='same'),
input_shape=(1, 100, X_train.shape[3])))
model.add(TimeDistributed(MaxPooling1D(pool_size=4)))
model.add(TimeDistributed(Dropout({{uniform(0, 1)}})))
model.add(TimeDistributed(Flatten()))
model.add(LSTM({{choice([32, 16])}}, activation='elu'))
model.add(Dense(1))
model.compile(optimizer='adam',
loss='mean_squared_error')
model_fitted = model.fit(X_train, y_train,
validation_data=[X_test, y_test],
batch_size=1000,
epochs=100,
verbose=1)
loss, rme, *_ = model_fitted.evaluete(X_test, y_test, verbose=0)
print(f'loss: {loss}, rme: {rme}')
return {'loss': -loss, 'status': STATUS_OK, 'model': model}
best_run, best_model = optim.minimize(model=model,
data=data,
max_evals=10,
algo=tpe.suggest,
notebook_name='injection_proj',
trials=Trials())
Traceback (most recent call last):
File "/home/mraevsky/.pyenv/versions/3.7.3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-32-a63d5421d872>", line 11, in <module>
trials=Trials())
File "/home/mraevsky/miniconda3/lib/python3.7/site-packages/hyperas/optim.py", line 69, in minimize
keep_temp=keep_temp)
File "/home/mraevsky/miniconda3/lib/python3.7/site-packages/hyperas/optim.py", line 98, in base_minimizer
model_str = get_hyperopt_model_string(model, data, functions, notebook_name, verbose, stack)
File "/home/mraevsky/miniconda3/lib/python3.7/site-packages/hyperas/optim.py", line 189, in get_hyperopt_model_string
imports = extract_imports(cleaned_source, verbose)
File "/home/mraevsky/miniconda3/lib/python3.7/site-packages/hyperas/utils.py", line 40, in extract_imports
tree = ast.parse(source)
File "/home/mraevsky/.pyenv/versions/3.7.3/lib/python3.7/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1557
plt.plot([:,0],)
^
SyntaxError: invalid syntax
Good afternoon!
Unfortunately, I stacked with such error while running the script in Jupyter Notebook: