Giter Site home page Giter Site logo

gentle_tensorflow's People

Contributors

nbigaouette-eai avatar nethsix avatar scott------ 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

gentle_tensorflow's Issues

suggest about learn_rate or steps

@nethsix Thanks for your tutorial :)

current

steps = 100
learn_rate = 0.0000001

I think it is better to adjust learn_rate or steps in the code because beginner who is not familiar with machine learning concept yet have question about value of W, b.

and what about adding the cost? I think it will show the how the cost is changed
ex) print("Cost: {0}".format(sess.run(cost, feed_dict=feed)))

"You must feed a value for placeholder tensor 'Placeholder_1' with dtype double and shape [?,1]"

Hi Khor,

Above all, thanks for your "linear_regression_one_feature.py" as I've finally understood what running linear regression in Tensorflow is after weeks of reading and tweaking.

I've tried to reproduce your code and simply exchange X and Y with data respectively on how often students go out with friends (from 1 to 5) and on profession of the father (from 0 to 4).

Here is the code:

import numpy as np
import tensorflow as tf
import csv

x = [3.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 2.0, 1.0, 3.0, 2.0, 3.0, 3.0, 2.0, 4.0, 3.0, 2.0, 5.0, 3.0, 1.0, 2.0, 1.0, 4.0, 2.0, 2.0, 2.0, 4.0, 3.0, 5.0, 2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3.0, 3.0, 2.0, 2.0, 2.0, 1.0, 4.0, 4.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 2.0, 3.0, 3.0, 4.0, 4.0, 2.0, 3.0, 2.0, 1.0, 1.0, 2.0, 2.0, 3.0, 4.0, 4.0, 4.0, 4.0, 3.0, 1.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 4.0, 4.0, 4.0, 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 3.0, 3.0, 2.0, 3.0, 4.0, 3.0, 1.0, 1.0, 2.0, 1.0, 3.0, 1.0, 2.0, 2.0, 4.0, 3.0, 4.0, 4.0, 2.0, 2.0, 3.0, 0.0, 4.0, 3.0, 2.0, 4.0, 4.0, 2.0, 2.0, 3.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.0, 4.0, 3.0, 2.0, 2.0, 3.0, 4.0, 4.0, 4.0, 3.0, 1.0, 3.0, 1.0, 1.0, 4.0, 3.0, 4.0, 3.0, 1.0, 1.0, 1.0, 1.0, 3.0, 4.0, 1.0, 1.0, 4.0, 1.0, 2.0, 4.0, 3.0, 1.0, 2.0, 1.0, 4.0, 1.0, 4.0, 4.0, 3.0, 3.0, 4.0, 2.0, 2.0, 1.0, 4.0, 2.0, 4.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 3.0, 1.0]

train_x = np.array(x) #printing train_x.dtype gives "float64"
train_x.shape = (394,1) # reshaping to be sure it fits the placeholder

train_y = np.array(y) #printing train_y.dtype gives "float64"
train_y.shape = (394,1) # reshaping to be sure it fits the placeholder

x = tf.placeholder(tf.float64,shape=(None,1)) #specifying placeholder dtype to fit my arrray's one
W = tf.Variable(tf.zeros([1,1],dtype=tf.float64)) #specifying dtype to fit the training set
b = tf.Variable(tf.zeros([1],dtype=tf.float64))
product = tf.matmul(x,W)
y = product + b
y_ = tf.placeholder(tf.float64,shape=(None,1)) #specifying placeholder dtype to fit my arrray's one

cost = tf.reduce_mean(tf.square(y_-y))

gradient = tf.train.GradientDescentOptimizer(0.001).minimize(cost)

with tf.Session() as sess:
init = tf.global_variables_initializer()
sess.run(init)

epochs = 1000
for i in range(epochs):
    feed = {x:train_x,y:train_y}
    sess.run(gradient,feed_dict=feed)
    if epoch % 50 == 0:
        print("After {} iteration".format(i),"W= {}".format(sess.run(W),\
                                                            "b= {}".format(sess.run(b))))
    print("Cost= {}".format(sess.run(cost,feed_dict=feed)))

The Traceback highlights "You must feed a value for placeholder tensor 'Placeholder_1' with dtype double and shape [?,1]" while placeholders' dtype and shape fit with those of the array. Here the full message:

2017-11-10 18:58:41.632505: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
Traceback (most recent call last):
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\client\session.py", line 1323, in _do_call
return fn(*args)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\client\session.py", line 1302, in _run_fn
status, run_metadata)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype double and shape [?,1]
[[Node: Placeholder_1 = Placeholderdtype=DT_DOUBLE, shape=[?,1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Grégory\eclipse-workspace\tensorflow_project\Udacity_1.py", line 42, in
sess.run(gradient,feed_dict=feed)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\client\session.py", line 889, in run
run_metadata_ptr)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\client\session.py", line 1120, in _run
feed_dict_tensor, options, run_metadata)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\client\session.py", line 1317, in _do_run
options, run_metadata)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\client\session.py", line 1336, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype double and shape [?,1]
[[Node: Placeholder_1 = Placeholderdtype=DT_DOUBLE, shape=[?,1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Caused by op 'Placeholder_1', defined at:
File "C:\Users\Grégory\eclipse-workspace\tensorflow_project\Udacity_1.py", line 29, in
y_ = tf.placeholder(tf.float64,shape=(None,1)) #specifying dtype to fit the training set
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1599, in placeholder
return gen_array_ops._placeholder(dtype=dtype, shape=shape, name=name)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 3090, in _placeholder
"Placeholder", dtype=dtype, shape=shape, name=name)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\framework\ops.py", line 2956, in create_op
op_def=op_def)
File "C:\python_for_tensorflow\tensorflow_env\lib\site-packages\tensorflow\python\framework\ops.py", line 1470, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder_1' with dtype double and shape [?,1]
[[Node: Placeholder_1 = Placeholderdtype=DT_DOUBLE, shape=[?,1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]


Do you have any idea on how to fix this?

Thanks a lot!

Greg

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.