how can we do this in pytorch?
After training the model, get the learned representations from the 2nd last FC layer for t-SNE visualization. The Model is defined below
class VisualNet(nn.Module):
def __init__(self):
super(VisualNet, self).__init__()
self.conv1 = nn.Conv2d() #Ignore the function values
slef.conv2 = nn.Conv1d()
slef.conv3 = nn.Conv1d()
slef.conv4 = nn.Conv1d(512,512)
self.fc1 = nn.Linear(512,256)
self.fc2 = nn.Linear(256, 8)
def forward(self, x):
x = self.conv1(self.conv2(self.conv3(self.conv4(x)))
x_fc1 = self.fc1(x)
x = self.fc2(x_fc1)
return x
model = VisualNet()
After finishing Training, How can I get x_fc1
embeddings
for t-SNE ??