技术博客 技术博客
  • JAVA
  • 仓颉
  • 设计模式
  • 人工智能
  • Spring
  • Mybatis
  • Maven
  • Git
  • Kafka
  • RabbitMQ
  • RocketMQ
  • Redis
  • Zookeeper
  • Nginx
  • 数据库套件
  • MySQL
  • Elasticsearch
  • MongoDB
  • Hadoop
  • ClickHouse
  • Hbase
  • Hive
  • Flink
  • Flume
  • SQLite
  • linux
  • Docker
  • Jenkins
  • Kubernetes
  • 工具
  • 前端
  • AI
GitHub (opens new window)
  • JAVA
  • 仓颉
  • 设计模式
  • 人工智能
  • Spring
  • Mybatis
  • Maven
  • Git
  • Kafka
  • RabbitMQ
  • RocketMQ
  • Redis
  • Zookeeper
  • Nginx
  • 数据库套件
  • MySQL
  • Elasticsearch
  • MongoDB
  • Hadoop
  • ClickHouse
  • Hbase
  • Hive
  • Flink
  • Flume
  • SQLite
  • linux
  • Docker
  • Jenkins
  • Kubernetes
  • 工具
  • 前端
  • AI
GitHub (opens new window)
  • JAVA

    • 基础

      • JAVA 锁 及 线程
      • JAVA NIO API
      • JVM 模块介绍
    • 版本

      • JAVA8 新特性总结
      • JAVA9 新特性总结
      • JAVA 10/11/12/13/14/15/16/17 新特性总结
    • 其他

      • jar 打包成.exe可执行文件
      • java代码混淆之 ProGuard
      • JAVA 性能监控(jvisualvm)及测试(JMeter)
      • Alibaba Arthas
      • jar启动脚本
  • 仓颉

    • 基础

      • 仓颉介绍
  • 设计模式

    • 代理模式
  • 人工智能

    • 线性回归
    • Pytorch
      • conda 介绍
        • 安装
        • conda 命令
      • scikit-learn
        • Pytorch
      • matplotlib
目录

Pytorch

# conda 介绍

conda 是一个开源的软件包管理系统和环境管理软件,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换。conda 是为 Python 程序创建的,类似于 Linux、MacOS、Windows,也可以打包和分发其他软件。 注!必须在 cmd 里面才可以,在 powershell 里面输入命令有些是无效的

https://www.anaconda.com/download 通过该地址,填写邮件,然后通过邮件去下载安装包,安装完成后。

conda 分为 anaconda 和 miniconda,anaconda 是一个包含了许多常用库的集合版本,miniconda 是精简版本(只包含 conda、pip、zlib、python 以及它们所需的包),剩余的通过 conda install command 命令自行安装即可;

# 安装

下载后需要查看环境变量,如果没有配置,需要自己配置

D:\tools\conda\Library\mingw-w64\bin
D:\tools\conda\Library\bin
D:\tools\conda\Scripts
D:\tools\conda
1
2
3
4

如果在下载的 miniconda 没找到 mingw-w64 目录,那么需要自己安装,通过下面命令就会安装一个 mingw-w64 目录

conda install m2w64-toolchain
1

# conda 命令

检查版本

conda --version
1

升级 conda

conda update conda
1

添加镜像源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/

下面这个我没用过, 可以添加一下试试看.
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/r/


目前国内提供conda镜像的大学
  清华大学: https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
  北京外国语大学: https://mirrors.bfsu.edu.cn/help/anaconda/
  南京邮电大学: https://mirrors.njupt.edu.cn/
  南京大学: http://mirrors.nju.edu.cn/
  重庆邮电大学: http://mirror.cqupt.edu.cn/
  上海交通大学: https://mirror.sjtu.edu.cn/
  哈尔滨工业大学: http://mirrors.hit.edu.cn/#/home
  (目测哈工大的镜像同步的是最勤最新的)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

查看已经添加的渠道

conda config --get channels
1

恢复默认镜像源

conda config --remove-key channels
1

# scikit-learn

Python 语言中专门针对机器学习应用而发展起来的一款开源框架 (算法库),可以实现 数据预处理 、 分类 、 回归 、 降维 、 模型选择 等常用的机器学习算法。其特点是集成各类机器学习算法,安装使用便捷,案例和文档丰富,但仅支持 Python 语言,不支持深度学习和强化学习。通过官网可查看其能解决的问题及对应案例,如线性回归属于回归问题,官网有相关模型介绍和调用方法。

下载速度过慢 我们也可以使用清华镜像源来下载安装

pip install scikit-learn  -i https://pypi.tuna.tsinghua.edu.cn/simple
1

创建一个虚拟环境

conda  create -n pytorch python=3.8
1
  • -n 指定虚拟环境名称
  • python=3.8 指定 python 版本

切换虚拟环境

conda activate pytorch
1

查看虚拟环境有哪些包

pip list
1

# Pytorch

官网地址:https://pytorch.org/ 进入官网后选择合适的 pytorch 版本,如果你没有 GPU,直接选择 CPU,如果你有 GPU,需要确认你的 GPU 是否支持 CUDA

查看 GPU 是否支持 CUDA,选择帮助 -> 系统信息


使用 nvidia-smi 检查 CUDA 版本是否兼容,CUDA9.2 以上只支持 Driver Version: 396.26 以上的

# matplotlib

matplotlib 是一个绘图库,它提供了许多绘图工具,如折线图、饼图、散点图、直方图等,并且可以生成多种格式的图表,如 PDF、SVG、PNG 等。学习地址:https://www.runoob.com/matplotlib/matplotlib-tutorial.html

安装 matplotlib

pip install -U matplotlib
1

案例

import matplotlib.pyplot as plt

if __name__ == '__main__':
    # 表示做一个 2行1列的表格,在表格第1行作图
    fig1 = plt.subplot(2,1,1)
    plt.scatter([1,2,3,4],[5,6,7,8]) # 线型图
    # 表示做一个 2行1列的表格,在表格第2行作图
    fig2 = plt.subplot(2,1,1)
    plt.scatter([1,2,3,4],[5,6,7,8]) # 线型图

1
2
3
4
5
6
7
8
9
10
上次更新: 6/11/2025, 4:10:30 PM
线性回归

← 线性回归

Theme by Vdoing | Copyright © 2023-2025
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式