Example #1
0
def valid_acc(sess, valid_x, y):
    div = y.shape[0]
    count = 0
    for i in range(div):
        temp_x = valid_x[i]
        #print (temp_x.shape)
        rotate90 = np.array(op.rotate18(temp_x, 90))
        rotate180 = np.array(op.rotate18(temp_x, 180))
        rotate270 = np.array(op.rotate18(temp_x, 270))

        fin_x = np.concatenate([temp_x, rotate90, rotate180, rotate270],
                               axis=0)
        fin_x = fin_x.reshape(-1, 32, 32, 18)
        #print (fin_x.shape)
        y_ = sess.run(pred_number,
                      feed_dict={
                          x: fin_x,
                          keep_prob: 1.0,
                          is_training: False
                      })
        y_ = np.argmax(np.bincount(y_))
        label = np.argmax(y[i])
        if (y_ == label):
            count = count + 1
    return count / div
Example #2
0
y_ = graph.get_tensor_by_name("conv/dense_2/BiasAdd:0")
loss = graph.get_tensor_by_name("conv_1/Mean:0")
#train=graph.get_operation_by_name("conv_1/Adam:0")
pred_number = graph.get_tensor_by_name("ArgMax:0")

#data IO
path = '..\\dataset\\round1_test_a_20181109.h5'
h = h5py.File(path, 'r')
sen2 = h['sen2'].value

num = sen2.shape[0]
ans = np.zeros((num, 17))

for i in range(num):

    img = sen2[i]
    img_90 = np.array(op.rotate18(img, 90, channle=10))
    img_180 = np.array(op.rotate18(img, 180, channle=10))
    img_270 = np.array(op.rotate18(img, 270, channle=10))

    fin_img = np.concatenate([img, img_90, img_180, img_270], axis=0)
    fin_img = fin_img.reshape(-1, 32, 32, 10)

    y_ = sess.run(pred_number, feed_dict={x: fin_img, keep_prob: 1.0})
    y_ = np.argmax(np.bincount(y_))

    ans[i][y_] = 1

np.savetxt("round1_test_a_20181109.csv", ans, delimiter=',')