intro to pytorch

1

one hot 解决了 multi attribute 用123, 会有预测值between them

2

已知X,y
np.argwher(y>1) return the indices
X[np.argwhere(y>1)] return the respetive X which its according y >1

for x, y in zip(x,y):

3 penalize

在这里插入图片描述
we want to penalize the large weight by regularization

4

use dropout
use random start to deal with local minimum
Batch vs Stochastic Gradient Descent
use Momentum to deal with local minimum

or in cv, we can also use pooling to make cnn more efficient

5

the difference between Logsoftmax and Softmax
the difference between optim.SGD and optim.Adam

6

Now we need to calculate the percentage of correct predictions. equals has binary values, either 0 or 1. This means that if we just sum up all the values and divide by the number of values, we get the percentage of correct predictions. This is the same operation as taking the mean, so we can get the accuracy with a call to torch.mean. If only it was that simple. If you try torch.mean(equals), you’ll get an error

RuntimeError: mean is not implemented for type torch.ByteTensor
This happens because equals has type torch.ByteTensor but torch.mean isn’t implemented for tensors with that type. So we’ll need to convert equals to a float tensor. Note that when we take torch.mean it returns a scalar tensor, to get the actual value as a float we’ll need to do accuracy.item().

normalize

You’ll also typically want to normalize images with transforms.Normalize. You pass in a list of means and list of standard deviations, then the color channels are normalized like so

input[channel] = (input[channel] - mean[channel]) / std[channel]

Subtracting mean centers the data around zero and dividing by std squishes the values to be between -1 and 1. Normalizing helps keep the network work weights near zero which in turn makes backpropagation more stable. Without normalization, networks will tend to fail to learn.
\

在这里插入图片描述
High-frequency components also correspond to the edges of objects in images, which can help us classify those objects.

dif

dense layers are fully connected
convolutional layers are locally connected

combine with matplot

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
image = mpimg.imread(‘data/curved_lane.jpg’)

plt.imshow(image)

capsule network vs pooling layer

cnn

use cv2 to convert picture into gray pic

print gray picture
要squeez
ax.imshow(np.squeeze(layer[0,i].data.numpy()), cmap=‘gray’)

style transfer

use gram matrix

识别数字的方法

CNN

multiple logistc regression

这是一个简单的linear classifier
把每个数字的pixel看做特征,每个数字的识别都看成是一个logistic regression, 用scipy.optim.minimize,求出每个digit的每个特征的系数,然后dot要识别的值,用np.argmax() return the max probability

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值