ref: a866abe3c36098d9c0bf5927b8d29258667755f6
parent: 0a2d6dfcb656108eaace165310245e7f74a5b360
author: jbuethe <jbuethe@amazon.de>
date: Wed Sep 28 12:18:34 EDT 2022
ported debug changes from fec_encoder_torch.py
--- a/dnn/training_tf2/fec_encoder.py
+++ b/dnn/training_tf2/fec_encoder.py
@@ -40,6 +40,8 @@
parser.add_argument('--num-redundancy-frames', default=64, type=int, help='number of redundancy frames per packet (default 64)') parser.add_argument('--extra-delay', default=0, type=int, help="last features in packet are calculated with the decoder aligned samples, use this option to add extra delay (in samples at 16kHz)")+ parser.add_argument('--debug-output', action='store_true', help='if set, differently assembled features are written to disk')+
args = parser.parse_args()
model, encoder, decoder = new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=1, cond_size=args.cond_size)
@@ -145,32 +147,21 @@
print(f"average redundancy rate: {int(round(sum(packet_sizes) / len(packet_sizes) * 50 / 1000))} kbps")-if False:
-
- # sanity check
- packets2 = read_fec_packets(packet_file)
+if args.debug_output:
+ import itertools
- print(f"{len(packets)=} {len(packets2)=}")-
- print(f"{packets[0][0, 0]=}")- print(f"{packets2[0][0, 0]=}")-
+ batches = [2, 4]
+ offsets = [0, 4, 20]
# sanity checks
# 1. concatenate features at offset 0
+ for batch, offset in itertools.product(batches, offsets):
- test_features_batch2 = np.concatenate([packet[:,-2:, :] for packet in packets], axis=1)
- print(f"{test_features_batch2.shape=}")+ stop = packets[0].shape[1] - offset
+ test_features = np.concatenate([packet[:,stop - batch: stop, :] for packet in packets[::batch//2]], axis=1)
- test_features_full_batch2 = np.zeros((test_features_batch2.shape[1], nb_features), dtype=np.float32)
- test_features_full_batch2[:, :nb_used_features] = test_features_batch2[0, :, :]
+ test_features_full = np.zeros((test_features.shape[1], nb_features), dtype=np.float32)
+ test_features_full[:, :nb_used_features] = test_features[0, :, :]
- test_features_full_batch2.tofile('test_features_batch2.f32')+ print(f"writing debug output {packet_file[:-4] + f'_torch_batch{batch}_offset{offset}.f32'}")+ test_features_full.tofile(packet_file[:-4] + f'_torch_batch{batch}_offset{offset}.f32')- # 2. concatenate in batches of 4
- test_features_batch4 = np.concatenate([packet[:,-4:, :] for packet in packets[::2]], axis=1)
- print(f"{test_features_batch4.shape=}")-
- test_features_full_batch4 = np.zeros((test_features_batch4.shape[1], nb_features), dtype=np.float32)
- test_features_full_batch4[:, :nb_used_features] = test_features_batch4[0, :, :]
-
- test_features_full_batch4.tofile('test_features_batch4.f32')--
⑨