Git Product home page Git Product logo

deepschool.io's Introduction

DeepSchool.io

License Binder

Sign up here for Udemy Course on Machine Learning (Use code DEEPSCHOOL-MARCH to get 85% off course).

Goals

  1. Make Deep Learning easier (minimal code).
  2. Minimise required mathematics.
  3. Make it practical (runs on laptops).
  4. Open Source Deep Learning Learning.
  5. Grow a collaborating practical community around DL.
  6. Memes: No seriously. Make DL fun and interactive, this means more Trump tweets.

Support Us

There's a few ways you can support this initiative:

  1. Sign up to the Udemy course above.
  2. Subscribe to our YouTube channel here.
  3. Star this repository and share it!

Contents

The following contents are each contained within a folder:

  1. Data Science (eg. Pandas)
  2. Deep Learning (Keras)
  3. Bayesian Learning (PyMC3)

Installation

We run all our notebooks on google colab. In order to do this:

  1. Get a google account.
  2. Click on this link to take you to the google Drive folder.
  3. Go to the DL-Keras folder (or any other topic that you wish to learn).
  4. Double click on the notebook and click on, 'open with colaboratory' (You need to haved signed into Google for this).
  5. Click on the 'Runtime' tab at the top and change to python3 and GPU. Now you are all good to go.

Meetup

First meetup node: https://www.meetup.com/DeepSchool-io/

YouTube playlist

Find the corresponding video tutorial here (not all notebooks have an associated video) https://www.youtube.com/playlist?list=PLIx9QCwIhuRS1SPS9LHF7VjvZyM1g2Swz

You can ask questions and join the development discussion:

  • On the DeepSchool-io Slack channel. Use this link to request an invitation to the channel.

deepschool.io's People

Contributors

alescontrela avatar choldgraf avatar dependabot[bot] avatar halhenke avatar nkbt avatar picarus avatar radovankavicky avatar sachinruk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deepschool.io's Issues

deepschool.io Lesson 01 - PenalisedRegression - Solutions Cell 13 type error

My Machine:
OS X Yosemite 10.10.5 16GB i7


CELL 13:

import numpy as np
from scipy import sparse
from scipy import ndimage
from sklearn.linear_model import Lasso
from sklearn.linear_model import Ridge
from sklearn.linear_model import ARDRegression
import matplotlib.pyplot as plt

def _weights(x, dx=1, orig=0):
x = np.ravel(x)
floor_x = np.floor((x - orig) / dx)
alpha = (x - orig - floor_x * dx) / dx
return np.hstack((floor_x, floor_x + 1)), np.hstack((1 - alpha, alpha))

def _generate_center_coordinates(l_x):
X, Y = np.mgrid[:l_x, :l_x].astype(np.float64)
center = l_x / 2.
X += 0.5 - center
Y += 0.5 - center
return X, Y

def build_projection_operator(l_x, n_dir):
""" Compute the tomography design matrix.

Parameters
----------

l_x : int
    linear size of image array

n_dir : int
    number of angles at which projections are acquired.

Returns
-------
p : sparse matrix of shape (n_dir l_x, l_x**2)
"""
X, Y = _generate_center_coordinates(l_x)
angles = np.linspace(0, np.pi, n_dir, endpoint=False)
data_inds, weights, camera_inds = [], [], []
data_unravel_indices = np.arange(l_x ** 2)
data_unravel_indices = np.hstack((data_unravel_indices,
                                  data_unravel_indices))
for i, angle in enumerate(angles):
    Xrot = np.cos(angle) * X - np.sin(angle) * Y
    inds, w = _weights(Xrot, dx=1, orig=X.min())
    mask = np.logical_and(inds >= 0, inds < l_x)
    weights += list(w[mask])
    camera_inds += list(inds[mask] + i * l_x)
    data_inds += list(data_unravel_indices[mask])
proj_operator = sparse.coo_matrix((weights, (camera_inds, data_inds)))
return proj_operator

def generate_synthetic_data():
""" Synthetic binary data """
rs = np.random.RandomState(0)
n_pts = 36.
x, y = np.ogrid[0:l, 0:l]
mask_outer = (x - l / 2) ** 2 + (y - l / 2) ** 2 < (l / 2) ** 2
mask = np.zeros((l, l))
points = l * rs.rand(2, n_pts)
mask[(points[0]).astype(np.int), (points[1]).astype(np.int)] = 1
mask = ndimage.gaussian_filter(mask, sigma=l / n_pts)
res = np.logical_and(mask > mask.mean(), mask_outer)
return res - ndimage.binary_erosion(res)

/root/miniconda3/lib/python3.6/site-packages/ipykernel_launcher.py:42: DeprecationWarning: object of type <class 'float'> cannot be safely interpreted as an integer.

TypeError Traceback (most recent call last)
in ()
2 l = 128
3 proj_operator = build_projection_operator(l, l / 7.)
----> 4 data = generate_synthetic_data()
5 proj = proj_operator * data.ravel()[:, np.newaxis]
6 proj += 0.15 * np.random.randn(*proj.shape)

in generate_synthetic_data()
63 mask_outer = (x - l / 2) ** 2 + (y - l / 2) ** 2 < (l / 2) ** 2
64 mask = np.zeros((l, l))
---> 65 points = l * rs.rand(2, n_pts)
66 mask[(points[0]).astype(np.int), (points[1]).astype(np.int)] = 1
67 mask = ndimage.gaussian_filter(mask, sigma=l / n_pts)

mtrand.pyx in mtrand.RandomState.rand (numpy/random/mtrand/mtrand.c:19746)()

mtrand.pyx in mtrand.RandomState.random_sample (numpy/random/mtrand/mtrand.c:15541)()

mtrand.pyx in mtrand.cont0_array (numpy/random/mtrand/mtrand.c:6141)()

TypeError: 'float' object cannot be interpreted as an integer

xvfb-run error?

I wanted to try the project and after running docker-compose http://0.0.0.0:8888 wasn't responding. I checked and there was no conflict of ports or so.

Here's the build log from the terminal:
Creating network "deepschoolio_default" with the default driver Building app Step 1/1 : FROM sachinruk/ml_class latest: Pulling from sachinruk/ml_class bd97b43c27e3: Pull complete 6960dc1aba18: Pull complete 2b61829b0db5: Pull complete 1f88dc826b14: Pull complete 73b3859b1e43: Pull complete b5726da2badf: Pull complete 7246c11a4887: Pull complete bd832a5f3d35: Pull complete dd1dafb8acfd: Pull complete 8067dca54168: Pull complete 03add0ec109c: Pull complete fdfb622e10f0: Pull complete 6bec0ed891da: Pull complete 08fd904fe6b7: Pull complete Digest: sha256:33bda32be618ddcbe3f68340bbd13c019b2d089f2b23020f3d631d4aba4aa226 Status: Downloaded newer image for sachinruk/ml_class:latest ---> 9b7da273d8ec Successfully built 9b7da273d8ec Successfully tagged deepschoolio_app:latest Creating deepschoolio_app_1 ... Creating deepschoolio_app_1 ... done Attaching to deepschoolio_app_1 app_1 | [I 10:42:02.883 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret app_1 | [W 10:42:02.932 NotebookApp] All authentication is disabled. Anyone who can connect to this server will be able to run code. app_1 | [I 10:42:02.944 NotebookApp] Serving notebooks from local directory: /notebook app_1 | [I 10:42:02.945 NotebookApp] 0 active kernels app_1 | [I 10:42:02.945 NotebookApp] The Jupyter Notebook is running at: http://0.0.0.0:8888/ app_1 | [I 10:42:02.946 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). ^CGracefully stopping... (press Ctrl+C again to force) Stopping deepschoolio_app_1 ... done

Now when I try to 'up' the image again I get this:
Building app Step 1/1 : FROM sachinruk/ml_class ---> 9b7da273d8ec Successfully built 9b7da273d8ec Successfully tagged deepschoolio_app:latest Starting deepschoolio_app_1 ... Starting deepschoolio_app_1 ... done Attaching to deepschoolio_app_1 app_1 | xvfb-run: error: Xvfb failed to start deepschoolio_app_1 exited with code 1

Shouldn't matter I guess but I'm on Mac OS Sierra. Have any idea how to solve it or proofing the Dockerfile?

Docker: docker-compose build error: unauthorized: authentication required

I cloned the git hub repo and follow the instruction and during the step
docker-compose up --build I got an ERROR: Service 'app' failed to build: unauthorized: authentication required and the build stopped.
I have pasted the 'script' output of my terminal below:[[email protected]:/Users/efrenk/my-dp2/deepschool]$ docker-compose up --build
Building app
Step 1 : FROM sachinruk/ml_class
latest: Pulling from sachinruk/ml_class
bd97b43c27e3: Pull complete
6960dc1aba18: Pull complete
2b61829b0db5: Pull complete
1f88dc826b14: Pull complete
73b3859b1e43: Pull complete
b5726da2badf: Extracting [=====================> ] 28.97 MB/66.24 MB
7246c11a4887: Download complete
7a07ff0b3e63: Downloading [=> ] 30.27 MB/758.8 MB
5fe15be538ae: Download complete
0809b6f05afd: Downloading [==> ] 21.06 MB/379.6 MB
1e01633f21c6: Downloading
0501a6e2b254: Waiting
8ba6f72053f2: Waiting
2aeec0f993a5: Waiting
ERROR: Service 'app' failed to build: unauthorized: authentication required
[[email protected]:/Users/efrenk/my-dp2/deepschool]$

Lesson 6 contraception.py

from keras.layers import Merge is decaperated for keras 2 .
On using keras.layers.Concatenate gives an Assertion Error.
Please help me with this.

Attention based LSTM

Sorry, for opening on the issue page.
Actually, this is not related to issue. But, I was wondering how we could enhance, "seq2seq" on Lesson:19. to Attention based LSTM. If you already have could you please share us your repo or gist.

Lesson 19: I need help. I'm getting "Exception has occurred: InvalidArgumentError" because of the line "targets: target_batch[:, 1:]})"

Hi, your class is awesome, but I've been struggling for a few days with an error. I just can't find a way to solve it. I'm using vscode and it occurs because of this line:

targets: target_batch[:, 1:]})

But it stops when I remove the next part:

for epoch_i in range(epochs):

    start_time = time.time()

    for batch_i, (source_batch, target_batch) in enumerate(batch_data(X_train, y_train, batch_size)):

        _, batch_loss, batch_logits = sess.run([optimizer, loss, logits],

            feed_dict = {inputs: source_batch,

             outputs: target_batch[:, :-1],

             targets: target_batch[:, 1:]})

    accuracy = np.mean(batch_logits.argmax(axis=-1) == target_batch[:,1:])

    print('Epoch {:3} Loss: {:>6.3f} Accuracy: {:>6.4f} Epoch duration: {:>6.3f}s'.format(epoch_i, batch_loss, 

                                                                      accuracy, time.time() - start_time))

But, of course, without that, I'm not training the model. So, can you please give me an advice to solve it, please?
The error that I get is the following:

Exception has occurred: InvalidArgumentError
Cannot assign a device for operation 'enc_embedding/read': Could not satisfy explicit device specification '' because the node was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'
Colocation Debug Info:
Colocation group had the following types and devices:
VariableV2: GPU CPU
Identity: CPU
Const: GPU CPU
GatherV2: GPU CPU
StridedSlice: GPU CPU
Unique: GPU CPU
Shape: GPU CPU
Cast: GPU CPU
UnsortedSegmentSum: GPU CPU
SparseApplyRMSProp: CPU

Colocation members and user-requested devices:
enc_embedding (VariableV2)
enc_embedding/read (Identity)
embedding_lookup/axis (Const)
embedding_lookup (GatherV2)
optimization/gradients/embedding_lookup_grad/Shape (Const)
optimization/gradients/embedding_lookup_grad/ToInt32 (Cast)
enc_embedding/RMSProp (VariableV2)
enc_embedding/RMSProp_1 (VariableV2)
optimization/RMSProp/update_enc_embedding/Unique (Unique)
optimization/RMSProp/update_enc_embedding/Shape (Shape)
optimization/RMSProp/update_enc_embedding/strided_slice/stack (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_1 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_2 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice (StridedSlice)
optimization/RMSProp/update_enc_embedding/UnsortedSegmentSum (UnsortedSegmentSum)
optimization/RMSProp/update_enc_embedding/SparseApplyRMSProp (SparseApplyRMSProp)

[[{{node enc_embedding/read}} = IdentityT=DT_FLOAT, _class=["loc:@enc_embedding"]]]

Caused by op 'enc_embedding/read', defined at:
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "c:\Users\jorge.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy_main
.py", line 45, in
cli.main()
File "c:\Users\jorge.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy/..\debugpy\server\cli.py", line 429, in main
run()
File "c:\Users\jorge.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy/..\debugpy\server\cli.py", line 266, in run_file
runpy.run_path(options.target, run_name=compat.force_str("main"))
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\jorge\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\jorge\Documents\U\2020 1er semestre\Skrit\Práctica.py", line 111, in
input_embedding = tf.Variable(tf.random_uniform((len(char2numX), embed_size), -1.0, 1.0), name='enc_embedding')
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 145, in call
return cls._variable_call(*args, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 141, in _variable_call
aggregation=aggregation)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 120, in
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 2441, in default_variable_creator
expected_shape=expected_shape, import_scope=import_scope)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 147, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 1104, in init
constraint=constraint)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py", line 1266, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 81, in identity
return gen_array_ops.identity(input, name=name)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 3994, in identity
"Identity", input=input, name=name)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3272, in create_op
op_def=op_def)
File "C:\Users\jorge\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1768, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'enc_embedding/read': Could not satisfy explicit device specification '' because the node was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'
Colocation Debug Info:
Colocation group had the following types and devices:
VariableV2: GPU CPU
Identity: CPU
Const: GPU CPU
GatherV2: GPU CPU
StridedSlice: GPU CPU
Unique: GPU CPU
Shape: GPU CPU
Cast: GPU CPU
UnsortedSegmentSum: GPU CPU
SparseApplyRMSProp: CPU

Colocation members and user-requested devices:
enc_embedding (VariableV2)
enc_embedding/read (Identity)
embedding_lookup/axis (Const)
embedding_lookup (GatherV2)
optimization/gradients/embedding_lookup_grad/Shape (Const)
optimization/gradients/embedding_lookup_grad/ToInt32 (Cast)
enc_embedding/RMSProp (VariableV2)
enc_embedding/RMSProp_1 (VariableV2)
optimization/RMSProp/update_enc_embedding/Unique (Unique)
optimization/RMSProp/update_enc_embedding/Shape (Shape)
optimization/RMSProp/update_enc_embedding/strided_slice/stack (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_1 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice/stack_2 (Const)
optimization/RMSProp/update_enc_embedding/strided_slice (StridedSlice)
optimization/RMSProp/update_enc_embedding/UnsortedSegmentSum (UnsortedSegmentSum)
optimization/RMSProp/update_enc_embedding/SparseApplyRMSProp (SparseApplyRMSProp)

[[{{node enc_embedding/read}} = IdentityT=DT_FLOAT, _class=["loc:@enc_embedding"]]]
File "C:\Users\jorge\Documents\U\2020 1er semestre\Skrit\Práctica.py", line 148, in
targets: target_batch[:, 1:]})

Lesson 19: Error while training. Please look into issue and help

Code: Lesson 19 - Seq2Seq - Date translator - Solutions.ipynb
for epoch_i in range(epochs):
start_time = time.time()
for batch_i, (source_batch, target_batch) in enumerate(batch_data(X_train, y_train, batch_size)):
_, batch_loss, batch_logits = sess.run([optimizer, loss, logits],
feed_dict = {inputs: source_batch,
outputs: target_batch[:, :-1],
targets: target_batch[:, 1:]
})

Error:
ValueError Traceback (most recent call last)
in ()
9 feed_dict = {inputs: source_batch,
10 outputs: target_batch[:, :-1],
---> 11 targets: np.array(target_batch[:, 1:])
12 })
13 accuracy = np.mean(batch_logits.argmax(axis=-1) == target_batch[:,1:])

/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata)
776 try:
777 result = self._run(None, fetches, feed_dict, options_ptr,
--> 778 run_metadata_ptr)
779 if run_metadata:
780 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata)
952 np_val = subfeed_val.to_numpy_array()
953 else:
--> 954 np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
955
956 if (not is_tensor_handle_feed and

/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/numpy/core/numeric.pyc in asarray(a, dtype, order)
529
530 """
--> 531 return array(a, dtype, copy=False, order=order)
532
533

ValueError: setting an array element with a sequence.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.