上午: AIoT資料分析應用系統框架設計與實作
今天教學一些Django的一些格式用法,及MTV架構代表對應的python檔案
from django.db import models
from 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.0
print(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 np
import torch
import torch.nn as nn
import matplotlib.pyplot as plt
import numpy as np
### step 1 load data and plot #############
torch.manual_seed(2)
X=torch.randn(100,1)*10
Y= X+torch.randn(100,1)*3
plt.scatter(X,Y)
xm=np.array([-30,30])
w=2
b=10
ym=w*xm+b
plt.plot(xm,ym,'r')