update
This commit is contained in:
@ -41,7 +41,6 @@ optimizer = torch.optim.SGD(net.parameters(), lr=0.5)
|
||||
loss_func = torch.nn.MSELoss() # this is for regression mean squared loss
|
||||
|
||||
plt.ion() # something about plotting
|
||||
plt.show()
|
||||
|
||||
for t in range(100):
|
||||
prediction = net(x) # input x and predict based on x
|
||||
|
||||
@ -47,7 +47,6 @@ optimizer = torch.optim.SGD(net.parameters(), lr=0.02)
|
||||
loss_func = torch.nn.CrossEntropyLoss() # the target label is NOT an one-hotted
|
||||
|
||||
plt.ion() # something about plotting
|
||||
plt.show()
|
||||
|
||||
for t in range(100):
|
||||
out = net(x) # input x and predict based on x
|
||||
|
||||
@ -32,4 +32,18 @@ net2 = torch.nn.Sequential(
|
||||
|
||||
|
||||
print(net1) # net1 architecture
|
||||
print(net2) # net2 architecture
|
||||
"""
|
||||
Net (
|
||||
(hidden): Linear (1 -> 10)
|
||||
(predict): Linear (10 -> 1)
|
||||
)
|
||||
"""
|
||||
|
||||
print(net2) # net2 architecture
|
||||
"""
|
||||
Sequential (
|
||||
(0): Linear (1 -> 10)
|
||||
(1): ReLU ()
|
||||
(2): Linear (10 -> 1)
|
||||
)
|
||||
"""
|
||||
@ -64,7 +64,6 @@ h_state = None # for initial hidden state
|
||||
|
||||
plt.figure(1, figsize=(12, 5))
|
||||
plt.ion() # continuously plot
|
||||
plt.show()
|
||||
|
||||
for step in range(60):
|
||||
start, end = step * np.pi, (step+1)*np.pi # time range
|
||||
|
||||
@ -85,7 +85,6 @@ loss_func = nn.MSELoss()
|
||||
# initialize figure
|
||||
f, a = plt.subplots(2, N_TEST_IMG, figsize=(5, 2))
|
||||
plt.ion() # continuously plot
|
||||
plt.show()
|
||||
|
||||
# original data (first row) for viewing
|
||||
view_data = Variable(train_data.train_data[:N_TEST_IMG].view(-1, 28*28).type(torch.FloatTensor)/255.)
|
||||
|
||||
@ -54,7 +54,7 @@ opt_D = torch.optim.Adam(D.parameters(), lr=LR_D)
|
||||
opt_G = torch.optim.Adam(G.parameters(), lr=LR_G)
|
||||
|
||||
plt.ion() # something about continuous plotting
|
||||
plt.show()
|
||||
|
||||
for step in range(10000):
|
||||
artist_paintings = artist_works() # real painting from artist
|
||||
G_ideas = Variable(torch.randn(BATCH_SIZE, N_IDEAS)) # random ideas
|
||||
|
||||
@ -57,7 +57,7 @@ opt_D = torch.optim.Adam(D.parameters(), lr=LR_D)
|
||||
opt_G = torch.optim.Adam(G.parameters(), lr=LR_G)
|
||||
|
||||
plt.ion() # something about continuous plotting
|
||||
plt.show()
|
||||
|
||||
for step in range(10000):
|
||||
artist_paintings, labels = artist_works_with_labels() # real painting, label from artist
|
||||
G_ideas = Variable(torch.randn(BATCH_SIZE, N_IDEAS)) # random ideas
|
||||
|
||||
@ -54,7 +54,6 @@ h_state = None # for initial hidden state
|
||||
|
||||
plt.figure(1, figsize=(12, 5))
|
||||
plt.ion() # continuously plot
|
||||
plt.show()
|
||||
|
||||
######################## Below is different #########################
|
||||
|
||||
|
||||
@ -58,7 +58,6 @@ optimizer_drop = torch.optim.Adam(net_dropped.parameters(), lr=0.01)
|
||||
loss_func = torch.nn.MSELoss()
|
||||
|
||||
plt.ion() # something about plotting
|
||||
plt.show()
|
||||
|
||||
for t in range(500):
|
||||
pred_ofit = net_overfitting(x)
|
||||
|
||||
@ -48,7 +48,6 @@ train_loader = Data.DataLoader(dataset=train_dataset, batch_size=BATCH_SIZE, shu
|
||||
# show data
|
||||
plt.scatter(train_x.numpy(), train_y.numpy(), c='#FF9359', s=50, alpha=0.2, label='train')
|
||||
plt.legend(loc='upper left')
|
||||
plt.show()
|
||||
|
||||
class Net(nn.Module):
|
||||
def __init__(self, batch_normalization=False):
|
||||
|
||||
Reference in New Issue
Block a user