rnnoise 運行報錯解決

./dump_rnn.py newweights9i.hdf5  rnn_data.c rnn_data.h

運行報錯信息如下:

Traceback (most recent call last):
  File "./dump_rnn.py", line 60, in <module>
    model = load_model(sys.argv[1], custom_objects={'msse': mean_squared_sqrt_error, 'mean_squared_sqrt_error': mean_squared_sqrt_error, 'my_crossentropy': mean_squared_sqrt_error, 'mycost': mean_squared_sqrt_error, 'WeightClip': foo})
  File "/Users/richard/Library/Python/2.7/lib/python/site-packages/keras/engine/saving.py", line 419, in load_model
    model = _deserialize_model(f, custom_objects, compile)
  File "/Users/richard/Library/Python/2.7/lib/python/site-packages/keras/engine/saving.py", line 317, in _deserialize_model
    model._make_train_function()
  File "/Users/richard/Library/Python/2.7/lib/python/site-packages/keras/engine/training.py", line 509, in _make_train_function
    loss=self.total_loss)
  File "/Users/richard/Library/Python/2.7/lib/python/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/Users/richard/Library/Python/2.7/lib/python/site-packages/keras/optimizers.py", line 511, in get_updates
    new_p = p.constraint(new_p)
TypeError: 'int' object is not callable

解決辦法:

#def foo(c, name):
#    return 1

#def mean_squared_sqrt_error(y_true, y_pred):
#    return K.mean(K.square(K.sqrt(y_pred) - K.sqrt(y_true)), axis=-1)

def mean_squared_sqrt_error(y_true, y_pred):
    return K.mean(K.square(K.sqrt(y_pred) - K.sqrt(y_true)), axis=-1)

def my_crossentropy(y_true, y_pred):
    return K.mean(2*K.abs(y_true-0.5) * K.binary_crossentropy(y_pred, y_true), axis=-1)

def mymask(y_true):
    return K.minimum(y_true+1., 1.)

def msse(y_true, y_pred):
    return K.mean(mymask(y_true) * K.square(K.sqrt(y_pred) - K.sqrt(y_true)), axis=-1)

def mycost(y_true, y_pred):
    return K.mean(mymask(y_true) * (10*K.square(K.square(K.sqrt(y_pred) - K.sqrt(y_true))) + K.square(K.sqrt(y_pred) - K.sqrt(y_true)) + 0.01*K.binary_crossentropy(y_pred, y_true)), axis=-1)

def my_accuracy(y_true, y_pred):
    return K.mean(2*K.abs(y_true-0.5) * K.equal(y_true, K.round(y_pred)), axis=-1)

class WeightClip(Constraint):
    def __init__(self, c=2,name='WeightClip'):
        self.c = c

        def __call__(self, p):
            #return {'name': self.__class__.__name__, 'c': self.c}
            return K.clip(p, -self.c, self.c)

        def get_config(self):
            return {'name': self.__class__.__name__, 'c': self.c}

model = load_model(sys.argv[1], custom_objects={'msse':msse, 'mean_squared_sqrt_error': mean_squared_sqrt_error, 'my_crossentropy':my_crossentropy, 'mycost':mycost, 'WeightClip':WeightClip})
#model = load_model(sys.argv[1], custom_objects={'msse': mean_squared_sqrt_error, 'mean_squared_sqrt_error': mean_squared_sqrt_error, 'my_crossentropy': mean_squared_sqrt_error, 'mycost': mean_squared_sqrt_error, 'WeightClip': foo})
 

對照上述修改完成,就可以成功運行!

rnnoise 具體訓練、應用,測試,技術優化,語音增強 歡迎大家加音頻算法討論羣:153268894 (作者 zeark)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章