batch_size=batch_size) # In[5]: cnn_params = { 'out_dims': [256, 256, 256, 128], 'kernel_sizes': 64, 'pool_sizes': 1 } c = cnn.model(seq_len=seq_len, input_op=input_op, **cnn_params) #a = tf.transpose(c.output, perm=[0, 2, 1]) #a = tf.nn.top_k(a, k=8, sorted=False, name='MAX_POOL').values #a = tf.transpose(a, perm=[0, 2, 1]) a = tf.reduce_mean(c.output, axis=1) fc = classifier.model(input_op=a, fc_sizes=[]) logits = fc.logits pred = fc.pred MODEL_PATH = '/tmp/balanced/' + c.name + fc.name MODEL_EXISTS = os.path.exists(MODEL_PATH) if MODEL_EXISTS: print('Model directory is not empty, removing old files') shutil.rmtree(MODEL_PATH) # In[6]: def measure_time(op, feed_dict={}, n_times=10): with tf.Session() as sess:
residual_input = tf.contrib.layers.max_pool2d( residual_input, kernel_size=[RESIDUAL_POOL, 1], stride=[RESIDUAL_POOL, 1]) c = cnn.model(seq_len=seq_len, input_op=residual_input, residual=True, keep_prob=keep_prob, model_name='CNN_block_%d' % i, **cnn_params) residual_input += c.output res_out = tf.squeeze(residual_input, axis=2) a = tf.reduce_mean(res_out, axis=1) fc = classifier.model(input_op=a, fc_sizes=[16], keep_prob=keep_prob) pred = fc.pred # ### Run predictor label_dict = {0: 'N', 1: 'A', 2: 'O', 3: '~'} saver = tf.train.Saver() with tf.Session() as sess: print('Sess started') coord = tf.train.Coordinator() saver.restore(sess, 'model/pool4--cnn32x64-64x64-64x64--fc16-20000') threads = tf.train.start_queue_runners(sess=sess, coord=coord) print('Evaluating') output = sess.run(pred,
# batch_size=batch_size, path='./data/train.TFRecord') input_op = tf.placeholder(tf.float32, [1, None]) seq_len = tf.placeholder(tf.float32, [1]) c = cnn.model(seq_len=seq_len, input_op=input_op, **cnn_params) r = rnn.get_model(batch_size=batch_size, seq_len=seq_len, input_op=c.output, **rnn_params) f = fourier.get_output(seq_len=seq_len, input_op=input_op, **fourier_params) td = time_domain.get_output(seq_len=seq_len, input_op=input_op, **time_domain_params) concatenated_features = tf.concat([r.last_output, f, td], 1) fc = classifier.model(input_op=concatenated_features, **fc_params) logits = fc.logits pred = fc.pred print('Building model... done!') # Load recording print('Loading record...', end=' ') # dir = "./validation/" assert len(sys.argv) == 2, "Wrong parameter list in the call of that script." fname = sys.argv[1] assert os.path.isfile(fname + ".mat"), "Not existing file: " + fname + ".mat" data = io.loadmat(fname + '.mat')['val'].astype(np.float32).squeeze() data -= data.mean() data /= data.std() print('done!')
batch_size=batch_size, path='./data/VALIDATION.TFRecord') validation_feed_dict = { input_op: val_input_op, seq_len: val_seq_len, label: val_label, batch_size: 128 } # In[5]: cnn_params = {'out_dims': [128, 256, 256], 'kernel_sizes': 64, 'pool_sizes': 1} c = cnn.model(seq_len=seq_len, input_op=input_op, **cnn_params) a = tf.reduce_mean(c.output, axis=1) fc = classifier.model(input_op=a, fc_sizes=[256, 256]) logits = fc.logits pred = fc.pred MODEL_PATH = '/tmp/balanced/' + c.name + fc.name MODEL_EXISTS = os.path.exists(MODEL_PATH) if MODEL_EXISTS: print('Model directory is not empty, removing old files') shutil.rmtree(MODEL_PATH) # In[6]: def measure_time(op, feed_dict={}, n_times=10): with tf.Session() as sess: