keras

How to use model input in loss function?

北城余情 提交于 2021-02-10 03:23:55
问题 I am trying to use a custom loss-function which depends on some arguments that the model does not have. The model has two inputs ( mel_specs and pred_inp ) and expects a labels tensor for training: def to_keras_example(example): # Preparing inputs return (mel_specs, pred_inp), labels # Is a tf.train.Dataset for model.fit(train_data, ...) train_data = load_dataset(fp, 'train).map(to_keras_example).repeat() In my loss function I need to calculate the lengths of mel_specs and pred_inp . This

How to use model input in loss function?

心已入冬 提交于 2021-02-10 03:23:25
问题 I am trying to use a custom loss-function which depends on some arguments that the model does not have. The model has two inputs ( mel_specs and pred_inp ) and expects a labels tensor for training: def to_keras_example(example): # Preparing inputs return (mel_specs, pred_inp), labels # Is a tf.train.Dataset for model.fit(train_data, ...) train_data = load_dataset(fp, 'train).map(to_keras_example).repeat() In my loss function I need to calculate the lengths of mel_specs and pred_inp . This

How to use Reshape keras layer with two None dimension?

喜你入骨 提交于 2021-02-09 09:35:41
问题 I have a keras 3D/2D model. In this model a 3D layer has a shape of [None, None, 4, 32]. I want to reshape this into [None, None, 128]. However, if I simply do the following: reshaped_layer = Reshape((-1, 128))(my_layer) my_layer has a shape of [None, 128] and therefore I cannot apply afterwards any 2D convolution, like: conv_x = Conv2D(16, (1,1))(reshaped_layer) I've tried to use tf.shape(my_layer) and tf.reshape, but I have not been able to compile the model since tf.reshape is not a Keras

Why keras use “call” instead of __call__?

我的未来我决定 提交于 2021-02-09 07:09:35
问题 I fond the following code in (https://www.tensorflow.org/tutorials/eager/custom_layers) class MyDenseLayer(tf.keras.layers.Layer): def __init__(self, num_outputs): super(MyDenseLayer, self).__init__() self.num_outputs = num_outputs def build(self, input_shape): self.kernel = self.add_variable("kernel", shape=[int(input_shape[-1]), self.num_outputs]) def call(self, input): return tf.matmul(input, self.kernel) The last two lines is call method, while it does not like usual python class method

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

女生的网名这么多〃 提交于 2021-02-09 05:58:44
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

穿精又带淫゛_ 提交于 2021-02-09 05:58:13
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

混江龙づ霸主 提交于 2021-02-09 05:55:40
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

只愿长相守 提交于 2021-02-09 05:55:34
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

Keras Concatenate TypeError: __init__() got multiple values for argument 'axis'

两盒软妹~` 提交于 2021-02-09 05:49:14
问题 I am currently trying to recreate the Unet. At the "upconvolution" part where the outputs of two layers needs to be merged I got the mentioned error. (TypeError: init () got multiple values for argument 'axis') Keras Version: 2.0.6 Tensorflow-gpu: 1.2.1 Code snippet: import gzip import os from six.moves import urllib import tensorflow as tf import numpy as np from keras.models import Sequential, Model from keras.layers import Input, Dropout, Flatten, Concatenate from keras.layers import

Keras Concatenate TypeError: __init__() got multiple values for argument 'axis'

与世无争的帅哥 提交于 2021-02-09 05:47:45
问题 I am currently trying to recreate the Unet. At the "upconvolution" part where the outputs of two layers needs to be merged I got the mentioned error. (TypeError: init () got multiple values for argument 'axis') Keras Version: 2.0.6 Tensorflow-gpu: 1.2.1 Code snippet: import gzip import os from six.moves import urllib import tensorflow as tf import numpy as np from keras.models import Sequential, Model from keras.layers import Input, Dropout, Flatten, Concatenate from keras.layers import