我目前在编译代码时遇到错误:TypeError: object of type 'NoneType' has no len()
,我不确定错误的来源。
基本上我要做的是在Keras中实现一个Autoencoder,它对编码器的输出执行任意操作作为解码器。使用张量流操作在tf_render_vst
中实现代码是不可行的。我已经编写了所有代码,但我不明白为什么它不起作用。这可能吗? - 到目前为止,我的代码粘贴在下面:
def tf_render_vst(x):
return tf.py_func(render_vst, [x], tf.float32)
def render_vst(x):
patch = rt.label_to_patch(x, fixed_params)
audio = rt.render_patch(patch, vst_path, render_config)
spect = rt.stft(audio)
return spect
input_img = Input(shape=(input_shape))
# encoding Layers
...
x = Dense(output_shape, activation='linear')(x)
encoded = Activation(soft_quantization)(x)
# Decoding Layer (render patch)
decoded = Lambda(tf_render_vst, trainable = False)(encoded)
# Full Model
autoencoder = Model(input_img, decoded)
# First Half of Autoencoder - the bit I'm interested in
encoder = Model(input_spec, encoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')
提前谢谢!
编辑:这是错误信息 -
~/.local/lib/python3.5/site-packages/keras/engine/training.py in compile(self, optimizer, loss, metrics, loss_weights, sample_weight_mode, weighted_metrics, target_tensors, **kwargs)
720 if target is None or K.is_placeholder(target):
721 if target is None:
--> 722 target = K.placeholder(ndim=len(shape),
723 name=name + '_target',
724 sparse=K.is_sparse(self.outputs[i]),
TypeError: object of type 'NoneType' has no len()