Giter Club home page Giter Club logo

dlwithtf's Introduction

TensorFlow for Deep Learning Companion Code

Referenced throughout the book.

Book Cover

TensorFlow Versions

The TensorFlow library has been evolving rapidly in the last couple years, and some of the code in this repo and the associated book no longer work with the latest versions of TensorFlow. We recommend using TensorFlow 1.6 for working through all exercises in this book. We are looking into creating a full requirements.txt file for all needed dependencies and hope to have that available for you soon.

We also welcome any PRs that modify code to work with more recent TensorFlow versions. We are looking into these upgrades on our end as well.

dlwithtf's People

Contributors

rbharath avatar rezazadeh 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

dlwithtf's Issues

Different bug in Ch. 3 linear regression code

Hi,
When I run this code, I get this error:
InvalidArgumentError: You must feed a value for placeholder tensor 'placeholders_6/Placeholder' with dtype float and shape [100,1]
at this line:
_, summary, loss = sess.run([train_op, merged, l], feed_dict=feed_dict)

My hunch is that it's because this line:
x_np = np.random.rand(N, 1)

creates integers rather than floats.

I'm using Python 2.7.6 and tensorflow 2.0.0 but I import TensorFlow like this:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

Bug in ch3 example of logistic regression

A type error is thrown when using '/' to calculate matrix sizes. Explicitly using the integer division operator ('//') seems to fix it. Very weird since N is being declared as an integer in the step before it.

Traceback (most recent call last): File "/home/ninja/Documents/github/dlwithtf/ch3/logistic_regression_tf.py", line 13, in <module> mean=np.array((-1, -1)), cov=.1*np.eye(2), size=(N/2,)) File "mtrand.pyx", line 4508, in mtrand.RandomState.multivariate_normal File "mtrand.pyx", line 1550, in mtrand.RandomState.standard_normal File "mtrand.pyx", line 167, in mtrand.cont0_array TypeError: 'float' object cannot be interpreted as an integer

I've also created a PR for this issue if you want to take a look.

#15

What do if the DeepChem install isn't working for me?

The TensorFlow for Deep Learning book uses DeepChem (https://deepchem.io/) for examples in Chapters 4, 5, and 8. While DeepChem installations work fine for most users, there are some users for whom DeepChem causes issues. If you're running into these issues, here are some steps we suggest:

  • Try asking a question on the DeepChem gitter chatroom. Please make sure to provide your OS, Python details, and if relevant a stack trace so we can help debug.
  • The Gitter can get crowded. If your question has not been answered, please raise an issue on the DeepChem GitHub . Please include all relevant information and we will try to help debug.
  • Only Chapters 4, 5, 8 in the TensorFlow book use DeepChem. You should be able to proceed while we help you work through any potential DeepChem issues.

We are working on putting together example code which doesn't rely on DeepChem for these chapters. We sincerely apologize if you've been facing difficulties and hope to help you find a quick resolution.

We will use this issue to track progress.

Type mismath in ch5/tox21_rf.py under python3

python3 ch5/tox21_rf.py outputs:

About to fit model on train set.
Traceback (most recent call last):
  File "tox21_rf.py", line 25, in <module>
    sklearn_model.fit(train_X, train_y)
  File "/home/alexander/env/tf/lib/python3.8/site-packages/sklearn/ensemble/_forest.py", line 330, in fit
    y, expanded_class_weight = self._validate_y_class_weight(y)
  File "/home/alexander/env/tf/lib/python3.8/site-packages/sklearn/ensemble/_forest.py", line 558, in _validate_y_class_weight
    check_classification_targets(y)
  File "/home/alexander/env/tf/lib/python3.8/site-packages/sklearn/utils/multiclass.py", line 172, in check_classification_targets
    raise ValueError("Unknown label type: %r" % y_type)
ValueError: Unknown label type: 'unknown'

It helps to replace line 14:

train_y = train_y[:, 0]

with

train_y = train_y[:, 0].astype('int')

Type mismatch in ch4/fcnet_classification_tf.py

Traceback (most recent call last):
  File "fcnet_classification_tf.py", line 17, in <module>
    y_zeros = np.zeros((N/2,))
TypeError: 'float' object cannot be interpreted as an integer

and in other lines. To correct, sed -i 's|N/2|N//2|g' ch4/fcnet_classification_tf.py.

Issue running code for Chapter 07(RNN)

Hi,
Thanks for the awesome repo. I am trying to run chapter 07 code and getting error at this line. The error message is as follows:

ValueError: Index out of range using input dim 2; input has only 2 dims for 'strided_slice_1' (op: 'StridedSlice') with input shapes: [20,20], [3], [3], [3] and with computed input tensors: input[3] = <1 1 1>.

I have noticed that input data is two dim while in this example you are slicing in three dims. Can you please propose a fix / work-around to this?

I have uploaded my code to this notebook!

Thanks!

Enhancement for Google Colab

Hi,

I am new to Deep Learning, TF, and tools. I am trying out the examples using Google Colab. One thing I am noticing with the Ch. 3 examples is that I am getting a "placeholder not set" kind of error after I have run the notebook once:

InvalidArgumentError: You must feed a value for placeholder tensor

One workaround is to select Runtime > Restart Runtime... from the menu which is a bit cumbersome and time consuming if you want to experiment with the example and run it many times.

A better approach would be to call tf.reset_default_graph() in the beginning of the program or right before the placeholders are created. I think this would make things easier for people relying on the Google Colab or similar environments.

Thank you,
Andrey

Automating hyper-parameter tuning

Hello,

I'm learning a lot from the book, and am beginning to write my own code now. I have a question about a statement in the section "Hyperparameter Optimization Algorithms" - in the box titled "CAN’T HYPERPARAMETER OPTIMIZATION BE AUTOMATED?" you mention that

"In recent years, there has been a surge of work focused on improving the algorithmic foundations of model tuning. Gaussian processes, evolutionary algorithms, and reinforcement learning have all been used to learn model hyperparameters and architectures with very limited human input"

Could you point me to some papers/references that use Gaussian processes or evolutionary algorithms to automate the tuning process?

Thank you,

Breakage due to TF Upgrades

Some of the code for the book is broken now due to changes in the latest version of TF. Please post breakages you've observed in this thread and we will coordinate a fix. PRs with fixes are welcome too!

Python3 incompabilities

In ch5/hidden_grid_search.py and possibly elsewhere:

File "hidden_grid_search.py", line 25, in <module>
    for params, param_scores in scores.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

Cure for python3: find . -type f -exec sed -i 's/iteritems()/items()/' {} +.

Bug in ch3 example of linear regression

Hi.
Thanks for this great deep learning examples!

There appears a bug in ch3 example linear_regression_tf.py
At line 42, y becomes shape(100,) but I think it should be (100,1) because y-y_pred becomes (100,100) given y_pred is (100,1). So the loss function is very largely overestimated.
Simply changing the 42 line as following makes the training converge to global minimum. (W=5, b=2)

y = tf.placeholder(tf.float32, (N,)) --> tf.placeholder(tf.float32, (N,1))

Of course, np.reshape should be removed from line 28 and some additional code change is necessary to make the script runnable.

So I don't think this example is a proper proof of gradient descent not converging to global minimum.

But I still deeply appreciate the great examples of tensorflow and it helps me with studying deep learning so much.
Thanks,

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.