GPU不可用时 sudo apt-get remove --purge nvidia*sudo apt-cache search nvidia*sudo sh NVIDIA-Linux-x86_64-470.86.runnvidia-smi
Dataset与DataLoader的使用 import numpy as npimport torchfrom torch.utils.data import Dataset, DataLoaderclass DiabetesDataset(Dataset):#定义一个糖尿病的数据集 def __init__(self, filepath): xy = np.loadtxt(filepath, delimiter=',', dtype=np.float32) self.len = xy.shape[0
理解RNN_恐龙岛 n_x,n_y:对一个样本而言,在某一个时间步输入输出向量的维数na:对一个输入样本而言,在一个时间步隐藏状态的数目现在训练由字母生成合适的单词(恐龙命名):X为训练样本中某个单词的字母列表,如X[a,b,c,z],正式处理前需要将其转换为独热码X[[0000],[10000],[01000],[001000],[000001]] (即:X[None,1,2,3,26])X左移生成Y – 整数列表,与X完全相同,但向左移动了一个索引。初始化a-1等参数之后,现在通过for循环将X[0]、X[
LTI连续离散系统时域分析方法(卷积理解) 在LTI连续系统中,以冲激函数作为基本信号,将任意信号分解,从而得到系统的零状态响应等于激励与系统冲激响应的卷积积分,而在LTI离散系统中,以单位序列(δ(k)=1,if k=0)为基本信号来分析较复杂的信号,LTI离散系统的零状态响应等于激励与系统的单位序列相应的卷积和(对应于卷积中的积分)。...
数据结构——链表的创建、赋值、反序与遍历 #include <stdio.h>typedef struct Note *PtrtoNote;struct Note{ int Data; PtrtoNote Next;};typedef PtrtoNote List;List Reverse(List);int main(void){ int n,i; PtrtoNote p; List L; Li...
Q Learning简单实现 括号拆开:Q(s,a) := (1-α)Q(s,a)+α[…]有(1-α)的概率相信以往的经验。"""A simple example for Reinforcement Learning using table lookup Q-learning method.An agent "o" is on the left of a 1 dimensional world, the trea...
Q Learns(Maze) maze_env.py"""Reinforcement learning maze example.Red rectangle: explorer.Black rectangles: hells [reward = -1].Yellow bin circle: paradise [reward = +1].All other ...
非监督学习——鸢尾花数据集 import torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvisionimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfrom matplotlib import cmimport numpy as ...
非监督学习——MNIST数据集 """View more, visit my tutorial page: https://morvanzhou.github.io/tutorials/My Youtube Channel: https://www.youtube.com/user/MorvanZhouDependencies:torch: 0.4matplotlibnumpy"""import torchim...
RNN_Regression """View more, visit my tutorial page: https://morvanzhou.github.io/tutorials/My Youtube Channel: https://www.youtube.com/user/MorvanZhouDependencies:torch: 0.4matplotlibnumpy"""from torchsumma...
LSTM对MNIST分类 import torchfrom torch import nnimport torchvision.datasets as dsetsimport torchvision.transforms as transformsimport matplotlib.pyplot as plt# torch.manual_seed(1) # reproducible# Hyper P...
快速搭建网络与保存 import torchimport matplotlib.pyplot as plt# torch.manual_seed(1) # reproducible# 用Pytorch有两种保存网络的方法,第一种是保存整个网络,第二种是只保存参数# 。第一种保存的文件相对较大,但是提取使用是较方便;第二种保存的文件相对较小,但是# 提取使用的时候要先定义网络结构。# fake ...
LeNet(Based on MNIST) import torchimport timeimport torchvision as tvimport torchvision.transforms as transformsimport torch.nn as nn # 各种层类型的实现import torch.optim as optim # 实现各种优化算法的包import argparseimport matplotl...
Classification Demo import torchimport matplotlib.pyplot as pltimport torch.nn.functional as F # 激励函数都在这from torch.autograd import Variable# 假数据n_data = torch.ones(100, 2) # 数据的基本形态 100行,两列的张量x0 = torc...
Regression Demo import torchfrom torch.autograd import Variableimport numpy as npimport torch.nn.functional as F # 激励函数都在这from torchsummary import summaryfrom torchviz import make_dotBATCH_SIZE = 5# BAT...
Pytorch_CNNDemo import osimport time# third-party libraryimport torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvisionimport matplotlib.pyplot as pltdevice = torch.device("cuda" if torch...
FPGA 输入捕获 串口数据上传 顶层模块module top_jishuqi( //system clock input sys_clk , // 时钟信号 input sys_rst_n, // 复位信号 //cymometer interface input cl...
FPGA USART发送字符串 module uart_send( input sys_clk, //系统时钟 input sys_rst_n, //系统复位,低电平有效 output reg uart_txd //UART发送端口 ); //pa...