【深度学习】kaggle使用

https://blog.csdn.net/2301_78630677/article/details/133834096
https://blog.csdn.net/xiaojia1001/article/details/139467176

https://www.kaggle.com/

使用要挂代理,要不然可能无法注册

绑定手机号之后才能使用GPU

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
每周30h免费GPU使用时长
在这里插入图片描述

上传数据集

Add Input: 添加kaggle平台上已有数据集。
upload:上传数据集,支持本地压缩文件,也支持指定一个远程的URL来下载

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
可以直接复制路径

基本使用

查看数据

df = pd.read_csv("/kaggle/input/fashionmnist/fashion-mnist_train.csv")
print(df.shape)

读取前三行数据

print(df.iloc[0:3,:])

label  pixel1  pixel2  pixel3  pixel4  pixel5  pixel6  pixel7  pixel8  \
0      2       0       0       0       0       0       0       0       0   
1      9       0       0       0       0       0       0       0       0   
2      6       0       0       0       0       0       0       0       5   

   pixel9  ...  pixel775  pixel776  pixel777  pixel778  pixel779  pixel780  \
0       0  ...         0         0         0         0         0         0   
1       0  ...         0         0         0         0         0         0   
2       0  ...         0         0         0        30        43         0   

   pixel781  pixel782  pixel783  pixel784  
0         0         0         0         0  
1         0         0         0         0  
2         0         0         0         0  

[3 rows x 785 columns]

FashionMnist是一个时装分类的图像数据集,每条数据的第一列为标签分类(0-9),表示10种时装分类。后面784列表示28x28图像展开后每一个像素的值。

使用GPU

import os 
import torch

print(f"cpu nums:{os.cpu_count()}")

# 检查是否有可用的 GPU
if torch.cuda.is_available():
    # 获取 GPU 设备信息
    for i in range(torch.cuda.device_count()):
        gpu = torch.cuda.get_device_properties(i)
        print("GPU {}:".format(i))
        print("型号:", gpu.name)
        print("核心数:", gpu.multi_processor_count)  # 核心数
        print("显存大小:", gpu.total_memory // (1024**2), "MB")  # 显存大小,转换为 MB
        print("-----------")
else:
    print("没有可用的 GPU。")

在这里插入图片描述
GPU主要用来加速pytorch。
tensorflow,pandas、numpy是不会加速的。

# 创建两个随机张量
a = torch.rand(3, 4)
b = torch.rand(4, 3)


# 将张量移动到GPU上
if torch.cuda.is_available():
    a = a.cuda()
    b = b.cuda()
    c = torch.matmul(a, b)
    print(f"a: {a}")
    print(f"b: {b}")
    print(f"c: {c}")

在这里插入图片描述
a、b、c三个矩阵均位于cuda 0号设备上。
CUDA是NVIDIA提供的一种GPU并行计算框架,在pytorch中使用 .cuda() 表示让我们的模型或者数据从CPU迁移到GPU上(默认是0号GPU),通过GPU开始计算。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开心星人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值