Giter Club home page Giter Club logo

tensorflowfun's People

Contributors

msyim avatar

Watchers

 avatar

tensorflowfun's Issues

Note on Logistic Regression

Method 1 in the code works fine:

# Method 1
hypothesis = tf.matmul(X,W) + b
cost = tf.nn.sigmoid_cross_entropy_with_logits(hypothesis, Y)
optimizer = tf.train.GradientDescentOptimizer(0.001).minimize(cost)
predicted = tf.cast(hypothesis > 0.5, dtype=tf.float32)
accuracy = tf.reduce_mean(tf.cast(tf.equal(predicted, Y), dtype=tf.float32))

However, the second method (which I believe is essentially the same as the first) doesn't seem to work:

# Method 2
hypothesis2 = tf.sigmoid(tf.matmul(X,W) + b)
cost2 = -tf.reduce_mean(Y * tf.log(hypothesis2) + (1-Y)*tf.log(1-hypothesis2))
optimizer2 = tf.train.GradientDescentOptimizer(0.001).minimize(cost2)
predicted2 = tf.cast(hypothesis2 > 0.5, dtype=tf.float32)
accuracy2 = tf.reduce_mean(tf.cast(tf.equal(predicted2, Y), dtype=tf.float32))

I get cost: nan
Need to investigate further on this issue....

Note on Linear Regression (correctly using ndarray)

It seemed like the model doesn't work when the input data has dimension >= 2:

x_train = [[1.,2.],[3.,4.]]
y_train = [4.,8.]

# Build a graph
X = tf.placeholder(tf.float32, shape=[None,2])
Y = tf.placeholder(tf.float32, shape=[None,1])

W = tf.Variable(tf.random_normal([2,1]), name='weight')
b = tf.Variable(tf.random_normal([1]), name='bias')

hypothesis = tf.matmul(X,W) + b
cost = tf.square(hypothesis - Y)

Clearly, the desired weight matrix is : [[1],[1]] and the bias : [1], but the model always converged to a point where the output is ~ [6,6] (and consequently, the loss ~ 4)

Studied the cost matrix whose dimension should be (2,1) but with the above code, the cost matrix had dimension: (2,2).

There was a problem in defining the y_train array. I had to change y_train to:

y_train = [[4.],[8.]]

Tensorflow does not seem to implicitly change the dimension as necessary (which is good)

MNIST log

For some reason, BN is not really helping ( in fact, NN using BN has worse performance than the ones not using BN). Will further investigate why.

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.