__author__ = 'Andres' tf.reset_default_graph() train_filename = '../test_w5120_g1024_h512_ex63501.tfrecords' valid_filename = '../test_w5120_g1024_h512_ex63501.tfrecords' signal_length = 5120 gap_length = 1024 batch_size = 256 fft_window_length = 512 fft_hop_size = 128 aTargetModel = EmptyTfGraph(shapeOfInput=(batch_size, signal_length), name="Target Model") anStftForTheInpaintingSetting = PreAndPostProcessor(signalLength=signal_length, gapLength=gap_length, fftWindowLength=fft_window_length, fftHopSize=fft_hop_size) anStftForTheInpaintingSetting.addStftForGapTo(aTargetModel) aTargetModel.divideComplexOutputIntoMagAndPhase() # (256, 11, 257, 2) aModel = EmptyTfGraph(shapeOfInput=(batch_size, signal_length), name="context encoder") anStftForTheInpaintingSetting.addStftForTheContextTo(aModel) aModel.divideComplexOutputIntoMagAndPhase() aModel.addReshape((batch_size, 16, 257, 4)) with tf.variable_scope("Encoder"): filter_shapes = [(7, 89), (3, 17), (2, 6), (1, 5), (1, 3)]
tf.reset_default_graph() if 'omenx' in socket.gethostname(): train_filename = '/store/nati/datasets/Nsynth/train_w5120_g1024_h512.tfrecords' valid_filename = '/store/nati/datasets/Nsynth/valid_w5120_g1024_h512.tfrecords' else: train_filename = '/scratch/snx3000/nperraud/data/NSynth/train_w5120_g1024_h512.tfrecords' valid_filename = '/scratch/snx3000/nperraud/data/NSynth/valid_w5120_g1024_h512.tfrecords' window_size = 5120 gap_length = 1024 batch_size = 256 fft_frame_length = 512 fft_frame_step = 128 aTargetModel = EmptyTfGraph(shapeOfInput=(batch_size, window_size), name="Target Model") with tf.name_scope('Remove_unnecesary_sides_before_stft'): signal = aTargetModel.output() signal_without_unnecesary_sides = signal[:, 1664:3456] aTargetModel.setOutputTo(signal_without_unnecesary_sides) aTargetModel.addSTFT(frame_length=fft_frame_length, frame_step=fft_frame_step) aTargetModel.divideComplexOutputIntoRealAndImaginaryParts( ) # (256, 11, 257, 2) aModel = EmptyTfGraph(shapeOfInput=(batch_size, window_size), name="context encoder") with tf.name_scope('Remove_gap_before_stft'): signal = aModel.output() left_side = signal[:, :2048]
import tensorflow as tf from network.emptyTFGraph import EmptyTfGraph from utils.legacy.contextEncoder import ContextEncoderNetwork __author__ = 'Andres' tf.reset_default_graph() train_filename = 'train_full_w5120_g1024_h512_ex18978619.tfrecords' valid_filename = 'valid_full_w5120_g1024_h512_ex893971.tfrecords' window_size = 5120 gap_length = 1024 batch_size = 256 aModel = EmptyTfGraph(shapeOfInput=(batch_size, window_size - gap_length), name="context encoder") dataset = aModel.output() first_half = dataset[:, :(window_size - gap_length) // 2] second_half = dataset[:, (window_size - gap_length) // 2:] stacked_halfs = tf.stack([first_half, second_half], axis=2) aModel.setOutputTo(stacked_halfs) with tf.variable_scope("Encoder"): aModel.addReshape((batch_size, 1, (window_size - gap_length) // 2, 2)) filter_shapes = [(1, 129), (1, 65), (1, 33), (1, 17), (1, 17), (1, 17)] input_channels = [2, 32, 128, 512, 256, 128] output_channels = [*input_channels[1:], 64] strides = [[1, 1, 2, 1]] * len(input_channels) names = ['First_Conv', 'Second_Conv', 'Third_Conv', 'Fourth_Conv', 'Fifth_Conv', 'Six_Conv'] aModel.addSeveralConvLayers(filter_shapes=filter_shapes, input_channels=input_channels,
from tensorflow.contrib import slim from network.emptyTFGraph import EmptyTfGraph from utils.legacy.stftMagContextEncoder import StftTestContextEncoder __author__ = 'Andres' tf.reset_default_graph() train_filename = '../test_w5120_g1024_h512_ex63501.tfrecords' valid_filename = '../test_w5120_g1024_h512_ex63501.tfrecords' window_size = 5120 gap_length = 1024 batch_size = 256 aModel = EmptyTfGraph(shapeOfInput=(batch_size, window_size), name="context encoder") signal = aModel.output() with tf.name_scope('Energy_Spectogram'): fft_frame_length = 512 fft_frame_step = 128 stft = tf.contrib.signal.stft(signals=signal, frame_length=fft_frame_length, frame_step=fft_frame_step) sides_stft = tf.stack((stft[:, :15, :], stft[:, 15 + 7:, :]), axis=3) mag_stft = tf.abs(sides_stft) # (256, 15, 257, 2) aModel.setOutputTo(mag_stft)
from tensorflow.contrib.signal.python.ops import window_ops from network.emptyTFGraph import EmptyTfGraph from utils.legacy.contextEncoder import ContextEncoderNetwork __author__ = 'Andres' tf.reset_default_graph() train_filename = '../test_w5120_g1024_h512_ex63501.tfrecords' valid_filename = '../test_w5120_g1024_h512_ex63501.tfrecords' window_size = 5120 gap_length = 1024 batch_size = 256 aModel = EmptyTfGraph(shapeOfInput=(batch_size, window_size - gap_length), name="context encoder") dataset = aModel.output() signal_length = window_size - gap_length first_half = dataset[:, :signal_length // 2] second_half = dataset[:, signal_length // 2:] stacked_halfs = tf.stack([first_half, second_half], axis=1) with tf.name_scope('Energy_Spectogram'): fft_frame_length = 512 fft_frame_step = 128 window_fn = functools.partial(window_ops.hann_window, periodic=True) stft = tf.contrib.signal.stft(signals=stacked_halfs, frame_length=fft_frame_length, frame_step=fft_frame_step,
import tensorflow as tf from network.emptyTFGraph import EmptyTfGraph from utils.legacy.stftMagContextEncoder import StftTestContextEncoder __author__ = 'Andres' tf.reset_default_graph() train_filename = 'test_full_w5120_g1024_h512_ex292266.tfrecords' valid_filename = 'test_full_w5120_g1024_h512_ex292266.tfrecords' window_size = 5120 gap_length = 1024 batch_size = 256 aModel = EmptyTfGraph(shapeOfInput=(batch_size, window_size - gap_length), name="context encoder") dataset = aModel.output() signal_length = window_size - gap_length first_half = dataset[:, :signal_length // 2] second_half = dataset[:, signal_length // 2:] stacked_halfs = tf.stack([first_half, second_half], axis=1) with tf.name_scope('Energy_Spectogram'): fft_frame_length = 512 fft_frame_step = 128 stft = tf.contrib.signal.stft(signals=stacked_halfs, frame_length=fft_frame_length, frame_step=fft_frame_step) mag_stft = tf.abs(stft) # (256, 2, 13, 257) mag_stft = tf.reshape(mag_stft, (batch_size, 13, 257, 2))