1.代码实现 from __future__ import print_function import theano import theano.tensor as T import numpy as np import matplotlib.pyplot as plt class Layer(object): def __init__(self, inputs, in_size, out_size, activation_function=None): self.W = theano.shar…
1. 过拟合问题可以通过调整机器学习的参数来完成,比如sklearn中通过调节gamma参数,将训练损失和测试损失降到最低 2. 代码实现(显示gamma参数对训练损失和测试损失的影响) from __future__ import print_function from sklearn.learning_curve import validation_curve from sklearn.datasets import load_digits from sklearn.svm import S…
1.代码实战 #!/usr/bin/env python #!_*_coding:UTF-8 _*_ import numpy as np from sklearn import preprocessing from sklearn.cross_validation import train_test_split from sklearn.datasets.samples_generator import make_classification from sklearn.svm import S…
各种优化器的比较 莫烦的对各种优化通俗理解的视频 import torch import torch.utils.data as Data import torch.nn.functional as F from torch.autograd import Variable import matplotlib.pyplot as plt # 超参数 LR = 0.01 BATCH_SIZE = EPOCH = # 生成假数据 # torch.unsqueeze() 的作用是将一维变二维,torc…
import torch from torch.autograd import Variable import matplotlib.pyplot as plt torch.manual_seed() # fake data x = torch.unsqueeze(torch.linspace(-,,),dim=) y = x.pow() + 0.2 * torch.rand(x.size()) x, y = Variable(x,requires_grad=False), Variable(y…
#!/usr/bin/env python #! _*_ coding:UTF-8 _*_ from Queue import Queue import time que = Queue() time_begin = time.time() # 如果a+b+c=1000, 且a^2+b^2=c^2,a,b,c为自然数,求出a,b,c所有的组合 # 使用枚举法计算结果 for a in range(1001): for b in range(1001): for c in range(1001):…