from __future__ import absolute_import, division, print_function

import os
import sys
sys.path.append(os.path.join('.', '..'))
import utils
import tensorflow as tf
import numpy as np

#(embedding_train,embedding_labels_train) = utils.read_tfrecords_train('tfRecords10procent/train.tfrecords')
#(embedding_val,embedding_labels_val) = utils.read_tfrecords_val('tfRecords10procent/val.tfrecords')

(e1_train, l1_train) = utils.tfRead('train1')
print("tfRecord train1 uploaded!")
(e2_train, l2_train) = utils.tfRead('train2')
print("tfRecord train2 uploaded!")
(e3_train, l3_train) = utils.tfRead('train3')
print("tfRecord train3 uploaded!")
(e4_train, l4_train) = utils.tfRead('train4')
print("tfRecord train4 uploaded!")
(e5_train, l5_train) = utils.tfRead('train5')
print("tfRecord train5 uploaded!")
(e6_train, l6_train) = utils.tfRead('train6')
print("tfRecord train6 uploaded!")
embedding_train = np.concatenate(
    (e1_train, e2_train, e3_train, e4_train, e5_train, e6_train), axis=0)
print("Train embedding shape: ", embedding_train.shape)

embedding_labels_train = np.concatenate(
    (l1_train, l2_train, l3_train, l4_train, l5_train, l6_train), axis=0)
print(embedding_labels_train.shape)
from __future__ import absolute_import, division, print_function

import os
import sys
sys.path.append(os.path.join('.', '..'))
import utils
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import confusion_matrix

(embedding_test, embedding_labels_test) = utils.tfRead('test')
print("tfRecord test2 uploaded!")

#embedding_labels_test = utils.labelMinimizer(embedding_labels_test)

embedding_list = embedding_test

gpu_opts = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)
# load the trained network from a local drive
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_opts)) as sess:
    #First let's load meta graph and restore weights
    saver = tf.train.import_meta_graph("C:/tmp/audio_classifier.meta")
    saver.restore(sess, tf.train.latest_checkpoint('C:/tmp/'))
    # Now, let's access and create placeholders variables and
    # create feed-dict to feed new data

    graph = tf.get_default_graph()
    x_pl = graph.get_tensor_by_name("xPlaceholder:0")
    feed_dict = {x_pl: embedding_list}
Пример #3
0
from __future__ import absolute_import, division, print_function

import os
import sys
sys.path.append(os.path.join('.', '..'))
import utils
import tensorflow as tf
import numpy as np

(e1_test, l1_test) = utils.tfRead('test1')
print("tfRecord test1 uploaded!")
(e2_test, l2_test) = utils.tfRead('test2')
print("tfRecord test2 uploaded!")

embedding_test = np.concatenate((e1_test, e2_test), axis=0)
print("Train embedding shape: ", embedding_test.shape)

embedding_labels_test = np.concatenate((l1_test, l2_test), axis=0)
print(embedding_labels_test.shape)

print(embedding_labels_test[195])
embedding_labels_test = utils.labelMinimizer(embedding_labels_test)
embedding_labels_test = utils.OnehotEnc(embedding_labels_test)

#print(embedding_test[1])
print(embedding_labels_test[195])

embedding_list = [embedding_test[195]]

gpu_opts = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)
# load the trained network from a local drive