import tensorflow.compat.v1 as tf

with tf.compat.v1.Session() as sess:
    tf.set_random_seed(777)

    filename_queue = tf.train.string_input_producer(['/Users/dong-wongim/Documents/playgroud/tensorflow/data-03-diabetes.csv'], shuffle=False, name='filename_quere')

    # text 파일 읽어오는 형식 지정
    reader = tf.TextLineReader()
    key, value = reader.read(filename_queue)

    record_default = [[0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.]]
    xy = tf.decode_csv(value, record_defaults = record_default)

     # collect batches of csv in
    train_x_batch, train_y_batch = \
        tf.train.batch([xy[0:-1], xy[-1:]], batch_size=10)

    X = tf.placeholder(tf.float32, shape=[None, 8])
    Y = tf.placeholder(tf.float32, shape=[None, 1])

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

    hypothesis = tf.sigmoid(tf.matmul(X,W)+b)

    cost  = -tf.reduce_mean(Y * tf.log(hypothesis) + (1-Y)*tf.log(1-hypothesis))
    train = tf.train.GradientDescentOptimizer(learning_rate=0.01).minimize(cost)

    predicted = tf.cast(hypothesis > 0.5, dtype=tf.float32)
    accuracy = tf.reduce_mean(tf.cast(tf.equal(predicted, Y), dtype = tf.float32))

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

        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(sess=sess, coord=coord)

        for step in range(10001):
            x_batch, y_batch = sess.run([train_x_batch, train_y_batch])
            feed = {X: x_batch, Y: y_batch}
            # sess.run(train, feed_dict=feed)
            cost_val, _ = sess.run([cost, train], feed_dict=feed)
            if step % 200 == 0:
                print(step, cost_val)
                # print(step, sess.run(cost, feed_dict=feed))

        coord.request_stop()
        coord.join(threads)

        print("Your first data-decode_csv", sess.run(hypothesis, feed_dict={X:[[0,0,0,0,0,0,0,0]]}))
        
d0ca63029566550a2c9e3888fba9c405ea1b37ea
<mask token>

<mask token>
with tf.compat.v1.Session() as sess:
    tf.set_random_seed(777)
    filename_queue = tf.train.string_input_producer([
        '/Users/dong-wongim/Documents/playgroud/tensorflow/data-03-diabetes.csv'
        ], shuffle=False, name='filename_quere')
    reader = tf.TextLineReader()
    key, value = reader.read(filename_queue)
    record_default = [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]]
    xy = tf.decode_csv(value, record_defaults=record_default)
    train_x_batch, train_y_batch = tf.train.batch([xy[0:-1], xy[-1:]],
        batch_size=10)
    X = tf.placeholder(tf.float32, shape=[None, 8])
    Y = tf.placeholder(tf.float32, shape=[None, 1])
    W = tf.Variable(tf.random_normal([8, 1]), name='weight')
    b = tf.Variable(tf.random_normal([1]), name='bias')
    hypothesis = tf.sigmoid(tf.matmul(X, W) + b)
    cost = -tf.reduce_mean(Y * tf.log(hypothesis) + (1 - Y) * tf.log(1 -
        hypothesis))
    train = tf.train.GradientDescentOptimizer(learning_rate=0.01).minimize(cost
        )
    predicted = tf.cast(hypothesis > 0.5, dtype=tf.float32)
    accuracy = tf.reduce_mean(tf.cast(tf.equal(predicted, Y), dtype=tf.float32)
        )
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(sess=sess, coord=coord)
        for step in range(10001):
            x_batch, y_batch = sess.run([train_x_batch, train_y_batch])
            feed = {X: x_batch, Y: y_batch}
            cost_val, _ = sess.run([cost, train], feed_dict=feed)
            if step % 200 == 0:
                print(step, cost_val)
        coord.request_stop()
        coord.join(threads)
        print('Your first data-decode_csv', sess.run(hypothesis, feed_dict=
            {X: [[0, 0, 0, 0, 0, 0, 0, 0]]}))

import tensorflow.compat.v1 as tf
with tf.compat.v1.Session() as sess:
    tf.set_random_seed(777)
    filename_queue = tf.train.string_input_producer([
        '/Users/dong-wongim/Documents/playgroud/tensorflow/data-03-diabetes.csv'
        ], shuffle=False, name='filename_quere')
    reader = tf.TextLineReader()
    key, value = reader.read(filename_queue)
    record_default = [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]]
    xy = tf.decode_csv(value, record_defaults=record_default)
    train_x_batch, train_y_batch = tf.train.batch([xy[0:-1], xy[-1:]],
        batch_size=10)
    X = tf.placeholder(tf.float32, shape=[None, 8])
    Y = tf.placeholder(tf.float32, shape=[None, 1])
    W = tf.Variable(tf.random_normal([8, 1]), name='weight')
    b = tf.Variable(tf.random_normal([1]), name='bias')
    hypothesis = tf.sigmoid(tf.matmul(X, W) + b)
    cost = -tf.reduce_mean(Y * tf.log(hypothesis) + (1 - Y) * tf.log(1 -
        hypothesis))
    train = tf.train.GradientDescentOptimizer(learning_rate=0.01).minimize(cost
        )
    predicted = tf.cast(hypothesis > 0.5, dtype=tf.float32)
    accuracy = tf.reduce_mean(tf.cast(tf.equal(predicted, Y), dtype=tf.float32)
        )
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(sess=sess, coord=coord)
        for step in range(10001):
            x_batch, y_batch = sess.run([train_x_batch, train_y_batch])
            feed = {X: x_batch, Y: y_batch}
            cost_val, _ = sess.run([cost, train], feed_dict=feed)
            if step % 200 == 0:
                print(step, cost_val)
        coord.request_stop()
        coord.join(threads)
        print('Your first data-decode_csv', sess.run(hypothesis, feed_dict=
            {X: [[0, 0, 0, 0, 0, 0, 0, 0]]}))

import tensorflow.compat.v1 as tf

with tf.compat.v1.Session() as sess:
    tf.set_random_seed(777)

    filename_queue = tf.train.string_input_producer(['/Users/dong-wongim/Documents/playgroud/tensorflow/data-03-diabetes.csv'], shuffle=False, name='filename_quere')

    # text 파일 읽어오는 형식 지정
    reader = tf.TextLineReader()
    key, value = reader.read(filename_queue)

    record_default = [[0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.]]
    xy = tf.decode_csv(value, record_defaults = record_default)

     # collect batches of csv in
    train_x_batch, train_y_batch = \
        tf.train.batch([xy[0:-1], xy[-1:]], batch_size=10)

    X = tf.placeholder(tf.float32, shape=[None, 8])
    Y = tf.placeholder(tf.float32, shape=[None, 1])

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

    hypothesis = tf.sigmoid(tf.matmul(X,W)+b)

    cost  = -tf.reduce_mean(Y * tf.log(hypothesis) + (1-Y)*tf.log(1-hypothesis))
    train = tf.train.GradientDescentOptimizer(learning_rate=0.01).minimize(cost)

    predicted = tf.cast(hypothesis > 0.5, dtype=tf.float32)
    accuracy = tf.reduce_mean(tf.cast(tf.equal(predicted, Y), dtype = tf.float32))

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

        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(sess=sess, coord=coord)

        for step in range(10001):
            x_batch, y_batch = sess.run([train_x_batch, train_y_batch])
            feed = {X: x_batch, Y: y_batch}
            # sess.run(train, feed_dict=feed)
            cost_val, _ = sess.run([cost, train], feed_dict=feed)
            if step % 200 == 0:
                print(step, cost_val)
                # print(step, sess.run(cost, feed_dict=feed))

        coord.request_stop()
        coord.join(threads)

        print("Your first data-decode_csv", sess.run(hypothesis, feed_dict={X:[[0,0,0,0,0,0,0,0]]}))
        