全连接神经网络mnist数据集训练

本文介绍了使用两个隐藏层,每层256个神经元的全连接神经网络在MNIST数据集上的训练过程。首次训练得到的准确率为0.9721,显示出模型的强大能力。然而,第二次训练结果为0.8251,揭示了训练结果的不稳定性以及学习率选择的重要性。
摘要由CSDN通过智能技术生成

两个隐藏层,每个隐藏层256个神经元,784行输入,1个输出。
It is interesting the first time I train the model with the learning rate 0.01, the accuracy is 0.9721 !!!
Amazing !!!
However, with the same paremeters, the second is 0.8251. This phenomenon indicates that the result is various at most times. Moreover, appropriate learning rate is of great importance as well.

# -*- coding: utf-8 -*-
"""
Created on Fri Dec  4 11:14:12 2020

@author: Melinda
"""

import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

learning_rate = 0.001
training_epoch = 25
batch_size = 10
display_step = 1

n_hidden_1 = 256
n_hidden_2 = 256
n_input = 784
n_classes = 10

x = tf.placeholder("float", [None, n_input])
y = tf.placeholder("float", [None, n_classes])

weights = {
   
    'h1': tf.Variable(tf.random_normal([n_input, n_hidden_1
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值