Skip to content

Commit

Permalink
把卷积隔离开,只训练卷积层
Browse files Browse the repository at this point in the history
  • Loading branch information
catpanda committed Dec 8, 2017
1 parent 459cca3 commit 5c4bb07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 10 additions & 1 deletion load.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@ def get_batch_data(train_data, train_label,index,batch_size):
filename = 'dataset.npy'
dataset = read_dataset(filename)
train_data, train_label = get_train_data(dataset)
print('==========================加载数据成功===========================')
dataset1 = []
for i in range(3200):
data = train_data[i]
label = train_label[i]
data = data / 127.5 - 1
dataset1.append([data,label])
#print(dataset1)
np.save("train.npy",dataset1)
#print(len(train_data))
#print('==========================加载数据成功===========================')
10 changes: 5 additions & 5 deletions net.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, layer_names, weights):
self.layer_names = layer_names
self.weights = weights
self.alpha = 0.1
self.batch_size = 32
self.batch_size = 8
self.step = 100
self.build()
self.set_training()
Expand Down Expand Up @@ -121,11 +121,11 @@ def loss(self, result, label, size):
prob_pre = tf.slice(self.result, [0, 7*7], [size, 7*7], name='prob_pre')
prob_label = tf.slice(label, [0, 7*7], [size, 7*7], name='prob_label')
# 预测横纵坐标
pos_pre = tf.slice(self.result, [0, 7*7*2], [size, 7*7*4], name='pos_pre')
pos_label = tf.slice(label, [0, 7*7*2], [size, 7*7*4], name='pos_label')
pos_pre = tf.slice(self.result, [0, 7*7*2], [size, 7*7*2], name='pos_pre')
pos_label = tf.slice(label, [0, 7*7*2], [size, 7*7*2], name='pos_label')
# 预测长宽尺寸
size_pre = tf.slice(self.result, [0, 7*7*4], [size, 7*7*6], name='size_pre')
size_label = tf.slice(label, [0, 7*7*4], [size, 7*7*6], name='size_label')
size_pre = tf.slice(self.result, [0, 7*7*4], [size, 7*7*2], name='size_pre')
size_label = tf.slice(label, [0, 7*7*4], [size, 7*7*2], name='size_label')
# 损失
class_loss = tf.reduce_sum(tf.square( class_pre - class_label ))
prob_loss = tf.reduce_sum(tf.square( prob_pre - prob_label ))
Expand Down

0 comments on commit 5c4bb07

Please sign in to comment.