Anaconda中软件库更新

今天在Anaconda运行Visualization of MLP weights on MNIST源码时出现了如图错误:

提示无法导入fetch_openml,查了一下是对应的sklearn软件包版本过低,为0.17版。需要更新到0.20版。

1.打开Anaconda Prompt命令行

输入 conda list 命令 查看Anaconda中软件包的版本,如图所示:

2.执行 conda update --all命令

更新后可查看sklearn此时版本已经更新为0.20.

3. Visualization of MLP weights on MNIST源码为:

"""
=====================================
Visualization of MLP weights on MNIST
=====================================Sometimes looking at the learned coefficients of a neural network can provide
insight into the learning behavior. For example if weights look unstructured,
maybe some were not used at all, or if very large coefficients exist, maybe
regularization was too low or the learning rate too high.This example shows how to plot some of the first layer weights in a
MLPClassifier trained on the MNIST dataset.The input data consists of 28x28 pixel handwritten digits, leading to 784
features in the dataset. Therefore the first layer weight matrix have the shape
(784, hidden_layer_sizes[0]).  We can therefore visualize a single column of
the weight matrix as a 28x28 pixel image.To make the example run faster, we use very few hidden units, and train only
for a very short time. Training longer would result in weights with a much
smoother spatial appearance.
"""
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_openml
from sklearn.neural_network import MLPClassifierprint(__doc__)# Load data from https://www.openml.org/d/554
X, y = fetch_openml('mnist_784', version=1, return_X_y=True)
X = X / 255.# rescale the data, use the traditional train/test split
X_train, X_test = X[:60000], X[60000:]
y_train, y_test = y[:60000], y[60000:]# mlp = MLPClassifier(hidden_layer_sizes=(100, 100), max_iter=400, alpha=1e-4,
#                     solver='sgd', verbose=10, tol=1e-4, random_state=1)
mlp = MLPClassifier(hidden_layer_sizes=(50,), max_iter=10, alpha=1e-4,solver='sgd', verbose=10, tol=1e-4, random_state=1,learning_rate_init=.1)mlp.fit(X_train, y_train)
print("Training set score: %f" % mlp.score(X_train, y_train))
print("Test set score: %f" % mlp.score(X_test, y_test))fig, axes = plt.subplots(4, 4)
# use global min / max to ensure all weights are shown on the same scale
vmin, vmax = mlp.coefs_[0].min(), mlp.coefs_[0].max()
for coef, ax in zip(mlp.coefs_[0].T, axes.ravel()):ax.matshow(coef.reshape(28, 28), cmap=plt.cm.gray, vmin=.5 * vmin,vmax=.5 * vmax)ax.set_xticks(())ax.set_yticks(())plt.show()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/440205.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Mac安装mysql8.x最简洁的步骤,避免采坑

1.下载mysql8的.dmg安装包(官网下载需要Oracle账号,推荐网上搜索一个8系列的版本即可) 2.双击.dmg安装包,不断点击下一步。但是需要注意以下两点: (1)密码认证方式都选第二个(不是…

Linux操作系统CentOS7安装

最近在学习Linux,今天记录下如何安装CentOS7操作系统。 1. 下载虚拟机软件 虚拟机选择的是VMware Workstation软件,可以访问这个链接下载:https://coding.net/u/aminglinux/p/resource/git/blob/master/README.md 2. 安装虚拟机 按照提示&…

机器学习初学者公众号下载资源汇总(一)

感谢黄海广博士的分享 原创: 机器学习初学者 机器学习初学者 今天 本站提供了大量的机器学习初学者下载资源,现在对已经公布的资源做下汇总,每个资源都会有一个百度云链接,并同时提供“自动回复”的功能(有时候百度云链…

Oracle和MySQL多表条件分页查询的高效SQL语句、MySQL分页查询总数total的获取

Oracle数据库分页查询: 利用rownum和between and关键字 -- 查询员工表和薪水表的分页sql(pageNo:页号从1开始,pageSize:每页大小) select* from(selectROWNUM rNo,user_id,user_name,user_dept,user_sal…

[通俗易懂]深入理解TCP协议(下):RTT、滑动窗口、拥塞处理

转自即时通讯网:http://www.52im.net/ 前言 此文为系列文章的下篇,如果你对TCP不熟悉的话,请先看看上篇《[通俗易懂]深入理解TCP协议(上):理论基础》 。 上篇中,我们介绍了TCP的协议头、状态机…

脑残式网络编程入门(一):跟着动画来学TCP三次握手和四次挥手

转自即时通讯网:http://www.52im.net/ 1、引言 网络编程中TCP协议的三次握手和四次挥手的问题,在面试中是最为常见的知识点之一。很多读者都知道“三次”和“四次”,但是如果问深入一点,他们往往都无法作出准确回答。 本篇文章尝…

【HDU - 5452】Minimum Cut(树形dp 或 最近公共祖先lca+树上差分,转化tricks,思维)

题干: Given a simple unweighted graph GG (an undirected graph containing no loops nor multiple edges) with nn nodes and mm edges. Let TT be a spanning tree of GG. We say that a cut in GG respects TT if it cuts just one edges of TT. Since love…

Idea自带的工具打jar包和Maven打Jar包(SpringBoot工程)

1.Idea自带的工具打jar包 (1)点击菜单栏的File后选中Project Structure,接着按如下图所示操作: (2)点击“OK”按钮后会出现下图的界面,然后继续点击“OK”按钮 (3)现在开…

图解算法学习笔记(目录)

今天遇到一本好书,如下,书很薄,不到200页,有将近400张图片,算法介绍的很有趣。这也是我读的第三本袁国忠先生翻译的书,向两位致敬。 目录大致如下; 第1章:二分查找和大O表示法; 第…

【POJ - 3249】Test for Job(DAG线性求带负权的最长路,dp)

题干: Mr.Dog was fired by his company. In order to support his family, he must find a new job as soon as possible. Nowadays, Its hard to have a job, since there are swelling numbers of the unemployed. So some companies often use hard tests for …

图解算法学习笔记(二): 选择排序

目录 1)数组和链表: 2)选择排序算法: 3)小结 本章内容: 两种基本数据结构:数组和链表; 选择排序算法; 1)数组和链表: 数组是连续的内存单元,链表可以不连续; 链表…

【HDU - 5456】Matches Puzzle Game(数位dp,思维)

题干: As an exciting puzzle game for kids and girlfriends, the Matches Puzzle Game asks the player to find the number of possible equations A−BCA−BC with exactly n (5≤n≤500)n (5≤n≤500) matches (or sticks). In these equations, A,BA,B and …

图解算法学习笔记(三):递归

本章内容&#xff1a; 学习递归&#xff1b;如何将问题分解成基线条件和递归条件。 1) 每个递归函数都有两部分&#xff1a;基线条件(base case)和递归条件(recursive base)。例如&#xff1a;打印3...2...1 def countdown(i):print(i)if i < 0:returnelse:countdown(i…

Apollo自动驾驶入门课程第⑨讲 — 控制(上)

目录 1. 简介 2. 控制流程 3. PID控制 4. PID优劣对比 本文转自微信公众号&#xff1a;Apollo开发者社区 原创&#xff1a; 阿波君 Apollo开发者社区 9月26日 上周我们发布了无人驾驶技术的 规划篇&#xff0c;车辆基于高精地图&#xff0c;感知和预测模块的数据来进行这一…

Apollo自动驾驶入门课程第⑩讲 — 控制(下)

目录 1. 线性二次调节器 2. 模型控制预测 3. 总结 本文转自微信公众号&#xff1a;Apollo开发者社区 原创&#xff1a; 阿波君 Apollo开发者社区 昨天 Apollo自动驾驶课程马上进入尾声&#xff0c;在无人驾驶技术控制篇&#xff08;上&#xff09;中&#xff0c;具体讲解了最…

图解算法学习笔记(四):快速排序

目录 1&#xff09; 示例1&#xff1a; 2&#xff09;快速排序 3) 再谈大O表示法 4&#xff09;小结 本章内容&#xff1a;学习分而治之&#xff0c;快速排序 1&#xff09; 示例1&#xff1a; 假设你是农场主&#xff0c;有一小块土地&#xff0c;你要将这块地均匀分成方…

图解算法学习笔记(五):散列表

目录 1&#xff09;示例1&#xff1a; 2&#xff09;散列函数 3&#xff09;应用案例 4&#xff09;冲突 5&#xff09;性能 6&#xff09;小结 本章内容&#xff1a; 学习散列表&#xff0c;最有用的数据结构之一。 学习散列表的内部机制&#xff1a;实现、冲突和散列函…

图解算法学习笔记(六):广度优先搜索

目录 1&#xff09;图简介 2&#xff09;图是什么 3&#xff09;广度优先搜索 4&#xff09;实现图 5&#xff09;实现算法 6&#xff09;小结 本章内容; 学习使用新的数据结构图来建立网络模型&#xff1b; 学习广度优先搜索&#xff1b; 学习有向图和无向图…

图解算法学习笔记(七):狄克斯特拉算法

目录 1&#xff09;使用狄克斯特拉算法 2&#xff09;术语 3&#xff09;实现 4&#xff09;小结 本章内容; 介绍加权图&#xff0c;提高或降低某些边的权重&#xff1b; 介绍狄克斯特拉算法&#xff0c;找出加权图中前往X的最短路径&#xff1b; 介绍图中的环…

【HDU - 5477】A Sweet Journey(思维,水题)

题干&#xff1a; Master Di plans to take his girlfriend for a travel by bike. Their journey, which can be seen as a line segment of length L, is a road of swamps and flats. In the swamp, it takes A point strengths per meter for Master Di to ride; In the f…