TypeError:call()获得了意外的关键字参数“ input_shape”

时间:2019-07-20 20:09:09

标签: python keras lstm

我正在实施一个LSTM,其火车数据的形状为(5237162,99,1)。

我按如下方式创建模型,但遇到错误。

public class MyService extends Service {

    NotificationManager notificationManager;
    Notification.Builder notification;
    private BroadcastReceiver receiver;

    @RequiresApi(api = Build.VERSION_CODES.O)    
    @Override
    public void onCreate() {
        super.onCreate();

        init_notification();
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();

                Toast.makeText(context,"Time is changed",Toast.LENGTH_LONG).show();

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    notificationManager.notify(NOTIFICATION_ID,notification.build());
                }

            }
        };

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(ACTION_TIME_CHANGED);

        registerReceiver(receiver, intentFilter);

        Toast.makeText(getApplicationContext(),"Service started",Toast.LENGTH_LONG).show();

    }

    @Override
    public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
        super.onStartCommand(intent, flags, startId);

        Toast.makeText(getApplicationContext(),"Time is changed",Toast.LENGTH_LONG).show();


        return START_STICKY;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if(receiver != null)    
          unregisterReceiver(receiver);
    }
}

我尝试将Keras从github升级到最新版本。不工作。

TypeError: call() got an unexpected keyword argument 'input_shape'

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

这很奇怪!在我的笔记本中运行代码可以正常运行。 我注意到“ input_shape”不是LSTM层的自变量,如显示on officially keras

也许是版本问题!

我的版本:keras'2.2.4',tensorflow'1.11.0'

要绕过它,您可以尝试功能性api:

from keras.layers import Input
input1 = Input(shape =( final_ip.shape[1],final_ip.shape[2] ) )
x = LSTM(256)(input1)

model = Model(input1,x)