Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workarounds in keras_example.ipynb #4

Open
nicolefinnie opened this issue Oct 16, 2019 · 0 comments
Open

Workarounds in keras_example.ipynb #4

nicolefinnie opened this issue Oct 16, 2019 · 0 comments

Comments

@nicolefinnie
Copy link

Hello Tobias,

I joined your hand-on session at PyConDE and I tried out your keras_example.ipynb. And I hit the following errors, so I wanted to post the workarounds to be able to get your notebook to work.

  • First, if you have a self certified server like myself, you might hit this issue during doing a handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)

Workaround is to bypass the error

#
import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
    # Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context
  • You might hit the error due to a change in numpy.load() in numpy=1.16.3, allow_pickle is False by default.
ValueError: Object arrays cannot be loaded when allow_pickle=False

Workaround for numpy 1.16.3, see tensorflow issue 28102

import numpy as np

# Override np.load() function for keras.datasets.reuters.load_data()
# where np.load() is called 
np_load_old = np.load
np.load = lambda *a, **k: np_load_old(*a, allow_pickle=True, **k)

print('Loading data...')
(x_train, y_train), (x_test, y_test) = reuters.load_data(num_words=max_words, test_split=0.2)

print(len(x_train), 'train sequences')
print(len(x_test), 'test sequences')

num_classes = np.max(y_train) + 1
print(num_classes, 'classes')

# restore np.load
np.load = np_load_old

# delete the temporary function object 
del(np_load_old)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant