Ejemplo n.º 1
0
    x_test, y_test, test_num = read_labels_batch_out(
        labels_path, (224, 224), (224, 224),
        root_images_folder,
        batch_size=batch_size,
        iteration_num=i,
        random_horizontal_flip=False)
    if (test_num == 0):
        break

    predicts = model.predict(x_test, batch_size=batch_size)

    for j, value in enumerate(predicts):
        predict = np.argmax(value)
        truth_val = y_test[j]
        confusion_mat.AddValueToConfusionMat(val=predict, label_val=truth_val)
        file_writer.Write("[[" + str(j + (batch_size * i)) + "]] " +
                          str(truth_val) + " {" + str(predict) + "}")

    print(
        "====================================================================")
    file_writer.Write(
        "====================================================================")

    print("result of iteration number : " + str(i))
    file_writer.Write("result of iteration number : " + str(i))
    print(" ")
    file_writer.Write(" ")

    print("---Show Current Score---\n")
    file_writer.Write("---Show Current Score---\n")
    print(confusion_mat.PrintConfusionMat())
    file_writer.Write(confusion_mat.PrintConfusionMat())
    print("---Images Means is Set to Zero---")
    print("Mean-subtracted values:", zip("BGR", np.array([0, 0, 0])))
else:
    mu = np.load(means_images_npy_path).mean(1).mean(1)
    transformer.set_mean('data', mu)  #Means From .npy Files
    print("---Images Means is Set by .npy Files---")
    print("Mean-subtracted values:", zip("BGR", mu))

net.blobs['data'].reshape(batch_size, image_color_channel, image_size_h,
                          image_size_w)

######################################################################################################
######################################################################################################
###################################################################################################

file_writer.Write(
    "====================================================================")
print("====================================================================")
print("for each layer, show the output shape")
file_writer.Write("for each layer, show the output shape")
for layer_name, blob in net.blobs.items():
    print(layer_name + "\t" + str(blob.data.shape))
    file_writer.Write(layer_name + "\t" + str(blob.data.shape))

print("====================================================================")
file_writer.Write(
    "====================================================================")
print(
    "The param shapes typically have the form (output_channels, input_channels, filter_height, filter_width) (for the weights) and the 1-dimensional shape (output_channels,) (for the biases)."
)
file_writer.Write(
    "The param shapes typically have the form (output_channels, input_channels, filter_height, filter_width) (for the weights) and the 1-dimensional shape (output_channels,) (for the biases)."