enter image description here我试图对两组数据(图像,但采用numpy数组格式)进行分类:目标和非目标。它们都相似,除了目标数据中包含小目标。分类时,我得到98%的准确率。当我做数据扩充时,目标数据只有361,这就是为什么,我移动了一些第一列和最后一列,而没有改变目标区域,准确率现在是100%。我不知道如何知道这个模型是否运行良好。你知道吗
我用的是有线电视新闻网,然后是最大池。转换3*3-32、-64、-32、-128、64和fc1,输出为2个单位。你知道吗
#loading the data
mat_trdata = io.loadmat('Target_Reduced.mat')
target = mat_trdata.get('TargetPNCC_Reduced')
#and so on to Non_Target
# Target
y = []
x_data=[]
y_data = []
y1=[]
new=[]
new1=[]
Tn = np.zeros(shape=(361, 39 * 200), dtype=np.float)
for i in range(361):
bufferr = target[:, :, i]
Tn[i, :] = np.reshape(bufferr, 39 * 200)
IM = np.reshape(bufferr, (39, 200))
new.append(IM)
y.append([1,0])
#Shifting the columns
x1=IM
x1[:, 0:55], x1[:, -55:] = x1[:, -55:].copy(), x1[:, 0:55].copy()
new1.append(x1)
y1.append([1,0])
#and so upto new5 and append y5[1,0]
x_data=new+new1+new2+new3+new4+new5
y_data=y+y1+y2+y3+y4+y5
# Non Target
ntn = np.zeros(shape=(3315, 39 * 200), dtype=np.float)
for i in range(3315):
buffer = nontarget[:, :, i]
ntn[i, :] = np.reshape(buffer, 39 * 200)
lm = np.reshape(buffer, (39, 200))
x_data.append(lm)
#append y[0,1]
y_data.append([0,1])
Batch_size: 64
Optimizer:Adam
training_iters = 200
learning_rate = 0.001
X_train, X_test, Y_train, Y_test =
model_selection.train_test_split(x_data, y_data,
train_size=0.50,test_size=0.50, random_state=101)
X_train = X_train.reshape(-1, 39, 200, 1)
X_test = X_test.reshape(-1,39,200,1)
def conv2d(x, W, b, strides=1):
x = tf.nn.conv2d(x, W, strides=[1, strides, strides, 1],
padding='SAME')
x = tf.nn.bias_add(x, b)
return tf.nn.relu(x)
def maxpool2d(x, k=2):
return tf.nn.max_pool(x, ksize=[1, k, k, 1], strides=[1, k, k,
1],padding='SAME')
weights = {..} #32,64,32,128,64 layers
biases = {..}
def conv_net(x, weights, biases):
conv1 = conv2d(x, weights['wc1'], biases['bc1'])
conv1 = maxpool2d(conv1, k=2)
#And so on upto conv5
# Fully connected layer
return out
#optimizer, prediction.. and etc
init = tf.global_variables_initializer(),
with tf.Session() as sess:
...
您可以使用用于深层模型(如显著性映射(https://www.analyticsindiamag.com/what-are-saliency-maps-in-deep-learning/))的解释技术来了解您的模型在做什么。请记住,虽然这样的地图是相当嘈杂,并不完全超级可靠,但他们总比没有好。你知道吗
这些映射背后的主要思想是查看模型相对于输入的梯度。如果某个像素的梯度值很大,那么小的变化将对输出产生很大的影响。您希望看到的数据是图像中间那些小目标区域上的大梯度。你知道吗
相关问题 更多 >
编程相关推荐