Open pjm4github opened 5 years ago
The remove_all_comments doesnt work correctly for nested comments nor for docstrings with " type quotes.
def create_model(x_train,y_train , x_test, y_test): # val_split=0.1, params=None):
"""
THIS DOCSTRING WILL NOT BE REMOVED
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.
"""
# commented line - the next line is not fully removed.
# model = Sequential() # additional end of line comment
model = Sequential()
model.add(
LSTM(
80,
input_shape=(None, 30),
return_sequences=True,
name='LTSM_1')
)
Suggested replacement inside site-packages/hyperas/utils.py
def remove_all_comments(source):
string = re.sub(re.compile("'''.*?'''", re.DOTALL), "", source) # remove '''...''' comments
string = re.sub(re.compile('""".*?"""', re.DOTALL), "", string) # remove """...""" comments
done = False
while not done:
len_string = len(string)
string = re.sub(re.compile("(?<!('|\").)*#.*?\n"), "\n", string) # remove #...\n comments
if len(string) == len_string:
done = True
return string
Before filing an issue, please make sure to tick the following boxes.
[x] Make sure your issue hasn't been filed already. Use GitHub search or manually check the existing issues, also the closed ones. Also, make sure to check the FAQ section of our readme.
[x] Install latest hyperas from GitHub: pip install git+git://github.com/maxpumperla/hyperas.git
[x] Install latest hyperopt from GitHub: pip install git+git://github.com/hyperopt/hyperopt.git
[x] We have continuous integration running with Travis and make sure the build stays "green". If, after installing test utilities with
pip install pytest pytest-cov pep8 pytest-pep8
, you can't successfully runpython -m pytest
there's very likely a problem on your side that should be addressed before creating an issue.[x] Create a gist containing your complete script, or a minimal version of it, that can be used to reproduce your issue. Also, add your full stack trace to that gist. In many cases your error message is enough to at least give some guidance.