上午: AIoT资料分析应用系统框架设计与实作
今天教学一些Django的一些格式用法,及MTV架构代表对应的python档案
from django.db import modelsfrom django.db.models.base import Model# Create your models here.class registration_info(models.Model): uid = models.CharField(max_length=20, unique=True, verbose_name='使用者名称') pwd = models.CharField(max_length=256) email = models.EmailField() signup_time = models.DateTimeField(auto_now_add=True) last_login = models.DateTimeField(auto_now=True) id_no = models.CharField(max_length=10) cellphone = models.CharField(max_length=10) address = models.TextField() webpage = models.URLField() dept = models.CharField(max_length=100) st = models.BooleanField() def __str__(self): return self.email
下午: Pytorch与深度学习初探
今日延续上次内容,推演梯度下降法的数学公式,也教了一些pytorch的语法
## python native type to torch.tensor 资料格式转换a=3.0print(type(a))a=torch.tensor(a)print(type(a))a=a.item()print(type(a))## python numpy to torch.tensor 资料格式转换print("============np array===")a=np.array([2,2])print(type(a))a=torch.from_numpy(a)print(type(a))a=a.numpy()print(type(a))
import numpy as npimport torchimport torch.nn as nnimport matplotlib.pyplot as pltimport numpy as np### step 1 load data and plot #############torch.manual_seed(2)X=torch.randn(100,1)*10Y= X+torch.randn(100,1)*3plt.scatter(X,Y)xm=np.array([-30,30])w=2b=10ym=w*xm+bplt.plot(xm,ym,'r')