问题描述
我是一名博士研究生,但不是深度学习或Python方面的专家,如果我的问题很琐碎,那么请抱歉。 我想做的是将快速dtw(https://pypi.org/project/fastdtw/)用作TensorFlow模型的损失函数。 (RNN) 定义函数后:
def dtw_distance (x,y):
distance,path=fastdtw(x,y)
return distance
我正在尝试使用它作为损失函数来编译我的模型:
from keras.callbacks import EarlyStopping,ModelCheckpoint
earlystopper = EarlyStopping(patience=10,verbose=1,monitor='loss')
checkpointer = ModelCheckpoint('model-dsbowl2018-1.h5',save_best_only=True,monitor='loss')
results = model.fit(train_av,train_ap,validation_split=0.1,batch_size=10,epochs=100,callbacks=[earlystopper,checkpointer])
我收到以下错误消息: TypeError:用户代码中:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:806 train_function *
return step_function(self,iterator)
<ipython-input-45-aacde9207c50>:2 dtw_distance *
distance,y)
fastdtw/_fastdtw.pyx:78 fastdtw._fastdtw.fastdtw **
fastdtw/_fastdtw.pyx:222 fastdtw._fastdtw.__prep_inputs
/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py:138 asanyarray
return array(a,dtype,copy=False,order=order,subok=True)
TypeError: __array__() takes 1 positional argument but 2 were given
即使在我的函数中添加了self参数,同样的错误仍然存在。 我在这里想念什么?
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)