学习进度笔记10

今天通过观看老师分享的TensorFlow的教学视频,初步学习了什么是逻辑回归的架构:

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets('data/',one_hot=True)
#print
trainimg = mnist.train.images
trainlabel = mnist.train.labels
testimg = mnist.test.images
testlabel = mnist.test.labels
print("trainlabel:",type(trainlabel),"shape:",trainlabel.shape)
print("trainimg:",type(trainimg),"shape:",trainimg.shape)
print("testlabel:",type(testlabel),"shape:",testlabel.shape)
print("testimg:",type(testimg),"shape:",testimg.shape)
print(trainlabel[0])

 

 输出的最后一行表示trainlabel的第一行代表的元素是7.

然后需要定义变量:

 

 首先利用TensorFlow的placeholder函数来对变量进行占坑,一遍后续数据的填入,其中None表示无穷。

然后初始化W和b变量,使用的是零初始化。

 

 制定学习参数和梯度下降优化器

posted @ 2021-01-13 18:32  20183602  阅读(69)  评论(0编辑  收藏  举报