我目前正在使用t-SNE来可视化数据特征。 首先,我从模型中提取特征向量
import torch.nn as nn
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.relu = nn.ReLU()
self.pool = nn.MaxPool2d((1, 2), stride=2)
self.normalize1 = nn.BatchNorm2d(16)
self.normalize2 = nn.BatchNorm2d(32)
self.conv1 = nn.Conv2d(6,16, (1, 6))
self.conv2 = nn.Conv2d(16,32, (1, 6))
self.fc1 = nn.Linear(32 * 1 * 20, 70)
self.fc2 = nn.Linear(70, 30)
self.fc3 = nn.Linear(30, 19)
self.drop1 = nn.Dropout2d(p=0.25)
def forward(self, x):
x = self.conv1(x)
x = self.normalize1(x)
x = self.relu(x)
x = self.conv2(x)
x = self.normalize2(x)
x = self.relu(x)
x = x.view(x.size()[0], -1)
feature1 = x
x = self.fc1(x)
x = self.relu(x)
x = self.drop1(x)
x = self.fc2(x)
x = self.relu(x)
x = self.fc3(x)
return feature1
使用TSNE绘制:
tsne = TSNE(n_components=2, perplexity=30, learning_rate=200, n_iter=1000).fit_transform(features_1[::2])
有人知道是什么导致数据特征看起来像一条线或一个圆而不是一个“块”吗? (我认为来自同一类的数据特征应该集中在一起?)
我能帮你修一下吗?还是结果正常
仅供参考,我的模型的测试精度约为0.69,这似乎告诉我我的模型运行正常
目前没有回答
相关问题 更多 >
编程相关推荐