matroid / matroid/dlwithtf

Bug in ch3 example of linear regression

Open
#14 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
322
Forks
155
PR merge metrics
No merged PRs in 30d

Description

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,

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect ch3 example linear_regression_tf.py, especially line 28's reshape and line 42's placeholder shape. Run the example and verify the target and prediction shapes, then confirm training converges to W=5 and b=2 without the loss being inflated by broadcasting.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.