Notebook使用方法说明

进入“人工智能”->“Notebook”“创建Notebook”这里共有三种开发工具:Jupyter、VS code和RStudio。

描述 描述

1.1 Jupyter

进入Jupyter模块,如图所示:

描述

相关选项说明: (1)名称:自定义命名创建的任务; (2) 开发工具:Notebook共提供三种开发工具:Jupyter、VS code和RStudio; (3) 框架版本:Jupyter共提供CPU和GPU两种框架; (4) 资源规格:Jupyter共提供三种不同配置的资源供选择。

--------------------------------测试用例 - 简单矩阵乘法-----------------------------------

1、输出pytorch的版本以及是否有GPU;

import torch
import time
from torch import autograd
torch.cuda.is_available()
print(torch.__version__)

描述

2、创建tensor及三次计算的耗时; 其中第一次是CPU计算,第二次和第三次是GPU计算。第二次比第一次时间明显减少,因为用了gpu加速;第三次比第二次同样少很多,应该是cpu存在缓存。

a=torch.randn(10000,1000)
b=torch.randn(1000,10000)
print(a)
print(b)

描述

t0=time.time()
c=torch.matmul(a,b)
t1=time.time()
print(a.device,t1-t0,c.norm(2))

描述

device=torch.device('cuda')
print(device)
a=a.to(device)
b=b.to(device)
t0=time.time()
c=torch.matmul(a,b)
t2=time.time()
print(a.device,t2-t0,c.norm(2))

描述

t0=time.time()
c=torch.matmul(a,b)
t2=time.time()
print(a.device,t2-t0,c.norm(2))

描述

1.2 VS code

点击“创建Notebook”,选择VS code模块,如图所示:

描述

相关选项说明 (1) 名称:自定义命名创建的任务; (2) 开发工具:Notebook共提供三种开发工具:Jupyter、VS code和RStudio; (3) 框架版本:VS code共提供pytorch和tensorflow两种框架; (4) 资源规格:VS code共提供三种不同配置的资源供选择。

--------------------------------测试用例 - 简单矩阵乘法-----------------------------------

1.3 RStudio

点击“创建Notebook”,选择Rstudio模块,如图所示:

描述 描述 (1)名称:自定义命名创建的任务; (2)开发工具:RStudio共提供三种开发工具:Jupyter、VS code和RStudio; (3)框架版本:RStudio共提供pytorch和tensorflow两种框架; (4)资源规格:RStudio共提供三种不同配置的资源供选择。

--------------------------------测试示例 - 正太分布画图-----------------------------------

画出随机变量X服从 N(0,0.5),N(0,1), N(0,2)累计分布曲线。

正态分布的累计分布函数是:

描述

累积分布函数的定义(cumulative distribution function):对连续函数,所有小于等于a的值,其 出现概率的和。F(a)=P(x<=a)。

> x = seq(-5,5,length.out=100)
> y <-pnorm(x,0,1)
> plot(x,y,col='red',xlim=c(-5,5),ylim = c(0,1),type='l',xaxs='i',ylab = 'density',xlab='+',main='the Normal Cumulative Distribution')
> line(x,pnorm(x,0,0.5),col='green')
> lines(x,pnorm(x,0,0.5),col='green')
> lines(x,pnorm(x,-2,1),col='orange')

描述

results matching ""

    No results matching ""