Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用model.fit()时,数据格式不正确,需要NHWC的数据格式 #6

Open
carrigeofboom opened this issue Oct 9, 2023 · 7 comments

Comments

@carrigeofboom
Copy link

以下是发生错误的代码
history = model.fit(x=X_train, y=y_train, batch_size = 100, epochs=400,
verbose=2, validation_data=(X_test, y_test),
shuffle=True, initial_epoch=0)

错误日志如下:

InvalidArgumentError Traceback (most recent call last)
e:\Git_repository\bear_fault_diagnosis\cnn_lstm_model.ipynb 单元格 11 line 1
----> 1 history = model.fit(x=X_train, y=y_train, batch_size = 100, epochs=400,
2 verbose=2, validation_data=(X_test, y_test),
3 shuffle=True, initial_epoch=0)

File d:\viewer\Conda\envs\failuredetection\lib\site-packages\keras\src\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb

File d:\viewer\Conda\envs\failuredetection\lib\site-packages\tensorflow\python\eager\execute.py:53, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
51 try:
52 ctx.ensure_initialized()
---> 53 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
54 inputs, attrs, num_outputs)
55 except core._NotOkStatusException as e:
56 if name is not None:

InvalidArgumentError: Graph execution error:
...
File "d:\viewer\Conda\envs\failuredetection\lib\site-packages\keras\src\optimizers\optimizer.py", line 276, in compute_gradients
grads = tape.gradient(loss, var_list)
Node: 'gradient_tape/model/conv1d_1/Conv1D/Conv2DBackpropInput'
Conv2DCustomBackpropInputOp only supports NHWC.
[[{{node gradient_tape/model/conv1d_1/Conv1D/Conv2DBackpropInput}}]] [Op:__inference_train_function_7795]

@Xiaohan-Chen
Copy link
Owner

报错的代码显示你使用了二维卷积,轴承故障数据一般为一维数据。将二维卷积替换为一维应该就可以解决。

@kiddada
Copy link

kiddada commented Oct 11, 2023

您好,我现在也在做故障诊断方面,昨天读了您的文章我想请问您的代码是不是不完整?(后面的精确率图没有画出来?)

@carrigeofboom
Copy link
Author

我没有对代码进行修改,数据集也是从官网直接下载的,不应该出现二维卷积吧

@kiddada
Copy link

kiddada commented Oct 27, 2023

你好,请问你的问题解决了吗我也遇到跟你一样的问题

@lhn384
Copy link

lhn384 commented Dec 13, 2023

你好,我也遇到这个问题请问你解决了吗

@Xiaohan-Chen
Copy link
Owner

可能是由于版本问题,当时使用的是tensorflow 1.14版本,keras也还没有集成在tensorflow中,所以与目前tensorflow 2.0版本差距较大。

@cjjcn
Copy link

cjjcn commented May 20, 2024

此问题是由于在CPU上运行时调用了GPU算子而导致的,解决方法是去除model内的各个channel设置参数(变回默认的last模式)),同时调整输入参数结构(即对换输入的两个维度大小)即可解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants