凤凰谷佛 2023-09-21 20:02 采纳率: 0%
浏览 23

深度学习模型的导入中遇到的问题

我在学习深度学习的过程中,第一次导入github上的项目时遇到如下报错

深度知识追踪模型的链接

https://github.com/lccasagrande/Deep-Knowledge-Tracing

pycharm的提示和报错信息如下:

信息一:

DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  dtype=np.float)
2023-09-21 19:13:07.394616: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
WARNING:tensorflow:Entity <function load_dataset.<locals>.<lambda> at 0x0000024CDE0FF5E8> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: No module named 'tensorflow_core.estimator'


信息二:

TypeError: Expected int32 passed to parameter 'depth' of op 'OneHot', got 7.0 of type 'float' instead. Error: Expected int32, got 7.0 of type 'float' instead.



  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-09-21 22:06
    关注

    【以下回答由 GPT 生成】

    问题解答

    根据报错信息,我们可以看到有两个问题需要解决。

    问题一:DeprecationWarning: np.float is a deprecated alias for the builtin float. To silence this warning, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here.

    这个问题是因为代码中使用了np.float,而这个别名已经被废弃。为了解决这个问题,我们只需将np.float替换为float即可。

    具体步骤如下: 1. 打开Deep-Knowledge-Tracing项目文件夹中相关的文件。 2. 在每个出现np.float的地方,将其替换为float

    例如,将以下代码:

    x = np.array([1.0, 2.0, 3.0], dtype=np.float)
    

    替换为:

    x = np.array([1.0, 2.0, 3.0], dtype=float)
    

    重复这个步骤,直到所有出现np.float的地方都被替换。

    问题二:TypeError: Expected int32 passed to parameter 'depth' of op 'OneHot', got 7.0 of type 'float' instead. Error: Expected int32, got 7.0 of type 'float'

    这个问题是因为在OneHot操作中,传入了一个类型为float的值,而预期要求传入的是int32类型的参数。

    具体步骤如下: 1. 找到报错信息所指的代码位置。 2. 查看相关代码,找到将浮点数传递给OneHot操作的地方。 3. 将传递给OneHot操作的浮点数转换为整数类型。

    例如,将以下代码:

    depth = 7.0
    one_hot_encoding = tf.one_hot(indices, depth)
    

    替换为:

    depth = int(depth)
    one_hot_encoding = tf.one_hot(indices, depth)
    

    确保传递给OneHot操作的参数类型为整数。

    重复这个步骤,直到所有传递给OneHot操作的参数类型为整数。

    通过以上步骤,我们可以解决这两个问题。

    注意:在修改代码之前,建议先做好备份以防出现意外情况。


    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

问题事件

  • 创建了问题 9月21日