TensorFlow 逻辑回归

该博客通过Python和TensorFlow库展示了如何实现逻辑回归模型,用于解决MNIST数据集的手写数字识别问题。博客详细介绍了数据加载、模型构建、损失函数、优化器选择以及训练过程。
摘要由CSDN通过智能技术生成

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import input_data

mnist      = input_data.read_data_sets('data/', one_hot=True)#帮助下载数据集并且分为训练集测试集等
trainimg   = mnist.train.images
trainlabel = mnist.train.labels
testimg    = mnist.test.images
testlabel  = mnist.test.labels
print ("MNIST loaded")

print (trainimg.shape)
print (trainlabel.shape)
print (testimg.shape)
print (testlabel.shape)
#print (trainimg)
print (trainlabel[0])

(55000, 784)#训练数据集数量和大小
(55000, 10)#训练数据集和标签
(10000, 784)#测试数据集数量和大小
(10000, 10)#测试数据集和标签
[0. 0. 0. 0. 0. 0. 0. 1. 0. 0.]#分类方式是属于就是1不属于就是0

初始化所有的参数y=w*x+b

x = tf.placeholder("float", [None, 784]) #placeholder先占据一个位置,不给付实际的值制定矩阵第一个是样本数目,第二个是像素个数
y

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值