• To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.


    关注 码龄 粉丝数 原力等级 -- 被采纳 被点赞 采纳率 大能猫238 2024-03-29 10:04 采纳率: 0% 浏览 120 首页/ 编程语言 / To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. python人工智能tensorflow 2024-03-29 09:59:11.164507: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. import matplotlib.pyplot as plt import numpy as np import tensorflow as tf TF_ENABLE_ONEDNN_OPTS = 0 boston_housing = tf.keras.datasets.boston_housing (train_x, train_y), (_, _) = boston_housing.load_data(test_split = 0) plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False titles = ["CRIN", "ZN", "INDUS", "CHAS", "NOX", "RM", "AGE", "DIS", "RAD", "TAX", "PTRATIO", "B-1000", "LSTAT", "MEDV"] plt.figure(figsize=(12, 12)) for i in range(13): plt.subplot(4, 4, (i + 1)) plt.scatter(train_x[:, i], train_y) plt.xlabel(titles[i]) plt.ylabel("Price($1000's)") plt.title(str(i + 1) + "." + titles[i] + " - Price") plt.tight_layout() plt.suptitle("各个属性与房价的关系", x = 0.5, y = 1.02, fontsize = 20) plt.show 运行波士顿房价绘图 出现错误 收起 写回答 好问题 0 提建议 追加酬金 关注问题 微信扫一扫 点击复制链接 分享 邀请回答 编辑 收藏 删除 结题 收藏 举报 追加酬金 (90%的用户在追加酬金后获得了解决方案) 当前问题酬金 ¥ 0 (可追加 ¥500) ¥ 15¥ 20¥ 50¥ 100¥ 200 支付方式 扫码支付 二维码出错 点击刷新 支付金额 15 元 提供问题酬金的用户不参与问题酬金结算和分配 支付即为同意 《付费问题酬金结算规则》 结题 再想想 删除 再等等

    3条回答 默认 最新

    • CSDN-Ada助手 CSDN-AI 官方账号 2024-03-29 12:20
      关注

      【以下回答由 GPT 生成】

      解决方案:

      这个错误提示是由于在TensorFlow中启用了oneDNN操作引起的。要解决这个问题,可以根据错误提示设置环境变量 TF_ENABLE_ONEDNN_OPTS=0

      以下是具体的解决步骤:

      1. 在代码中添加以下行,设置环境变量 TF_ENABLE_ONEDNN_OPTS=0
      import os
      os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
      
      1. 将上述代码放在导入TensorFlow库之前,确保在使用TensorFlow之前设置了该环境变量。

      修改后的完整代码示例如下:

      import os
      os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
      
      import matplotlib.pyplot as plt
      import numpy as np
      import tensorflow as tf
      
      boston_housing = tf.keras.datasets.boston_housing
      (train_x, train_y), (_, _) = boston_housing.load_data(test_split = 0)
      
      plt.rcParams['font.sans-serif'] = ['SimHei']
      plt.rcParams['axes.unicode_minus'] = False
      
      titles = ["CRIN", "ZN", "INDUS", "CHAS", "NOX", "RM", "AGE", "DIS", "RAD", "TAX",
                "PTRATIO", "B-1000", "LSTAT", "MEDV"]
      plt.figure(figsize=(12, 12))
      
      for i in range(13):
          plt.subplot(4, 4, (i + 1))
          plt.scatter(train_x[:, i], train_y)
          plt.xlabel(titles[i])
          plt.ylabel("Price($1000's)")
          plt.title(str(i + 1) + '.' + titles[i] + ' - Price')
      
      plt.tight_layout()
      plt.suptitle("Relationship between various attributes and house prices", x=0.5, y=1.02, fontsize=20)
      plt.show()
      

      通过上述步骤设置环境变量,您应该能够解决在运行Boston房价图表时出现的错误。如果问题仍然存在,请让我知道。


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

      展开全部

      评论
      枫清影寒 2024-04-20 19:59

      谢谢

      回复
    • 专家-赤兔[在线] 全栈领域优质创作者 2024-03-29 10:04
      关注

      引自免费微信小程序:皆我百晓生

      在 TensorFlow 中,如果你试图关闭 tf.enable_onednn_opts 变量的环境变量设置,可能会遇到以下问题:

      1. TF 使用了 On-DNN 运算(oneDNN),这是一类基于全连接层进行并行计算的技术,通常用于解决大规模数据集上的特征表示、模型训练等任务。
      2. 设置 tf.enable_onednn_opts 变量的目的是为了开启或者关闭支持在多个 CPU 映射上并行执行 OneDNN 的选项。默认情况下,它将打开,允许 ONNX 模型在多核处理器上实现并行计算。
      3. tf.enable_onednn_opts 被设置为零时,TensorFlow 将不会启用在单个 CPU 映射上并行执行 On-DNN 操作,这会导致性能下降。这是因为在一个 CPU 上运行一个完整 OneDNN 模型可能涉及到许多复杂的操作和递归调用,这些操作通常无法在单个CPU上同时完成。

      当您想要在图形化显示中仅显示某个属性(如 'CRIN' 或 'TAX')与房价之间的关系时,通常会通过以下几个步骤来处理:

      1. 获取数据:首先,从 Boston Housing 数据集中加载数据集。您可以通过以下代码获取这些数据:
      boston_dataset = tf.keras.datasets.boston_housing
      (train_x, train_y), (_ unseen_train_x, _ unseen_train_y), _ unseen_test_x, _ unseen_test_y = boston_dataset.load_data(test_split = 0)
      
      1. 分割数据:将 traintest 列表分开,并分别处理它们的特征向量。
      train_x = train_x.reshape((len(train_x), -1))
      train_y = train_y.astype(np.float32)
      
      unseen_train_x = unseen_train_x.reshape((len(unseen_train_x), -1))
      unseen_train_y = unseen_train_y.astype(np.float32)
      
      test_x = test_x.reshape((len(test_x), -1))
      test_y = test_y.astype(np.float32)
      
       unseen_test_x = unseen_test_x.reshape((len(unseen_test_x), -1))
      unseen_test_y = unseen_test_y.astype(np.float32)
      
      1. 提取特徵:在对 trainunseen_train 列表进行分块之前,我们需要获取各自列的特征值。例如,在 boston_dataset 中,特征名为 'CRIM', 'ZN', 'INDUS', 'chas', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B-1000', 'LSTAT'。您可以根据您的具体需求提取这些特征,如直方图、箱线图、热力图等。
      # 假设我们只关心 CRIM 特征
      crim_values_train = train_x[0]
      crim_values_unseen = unseen_train_x[0]
      
      # 假设我们只关心 ZN 特征
      zn_values_train = train_x[1]
      zn_values_unseen = unseen_train_x[1]
      
      # ... (根据实际情况添加其他特征提取代码)
      
      # 统计各特征的权重
      feature_weights_train = np.mean(crim_values_train)
      feature_weights_unseen = np.mean(zn_values_unseen)
      
      # 计算房价相关系数
      price_corr_matrix = feature_weights_train * unseen_train_y.T / feature_weights_unseen.T
      price_corr_matrix[:10, :10]
      
      1. 绘制图形:接下来,我们可以使用 matplotlib 库创建一个包含 'CRIN' 和 'TAX' 属性的柱状图,显示不同属性与房价的相关性。
      import matplotlib.pyplot as plt
      
      # 创建柱状图实例
      fig, ax = plt.subplots()
      
      # 定义柱状图布局
      bar_width = 0.85
      bottom_padding = 0.2
      left_padding = 0.2
      right_padding = 0.2
      top_padding = 0.2
      
      # 绘制柱状图
      ax.barh(range(len(crim_values_train)), [price_corr_matrix[i] for i in range(len(crim_values_train))],
              bottom=bottom_padding,
              width=bar_width,
              label='CRIM')
      
      # 添加坐标轴标签
      ax.set_xlabel('CRIM Values')
      ax.set_ylabel('Price Correlation Matrix')
      
      # 设置横轴刻度单位
      ax.yaxis.set_major_locator(multipleLocator(1))
      
      # 配置图表标题和字体大小
      ax.set_title('Relationship between CRIM and Property Prices',
                    fontdict={'fontsize': 18})
      
      # 添加边框和内填充
      ax.tick_params(axis="both", which="major", color=".5", alpha=0.5)
      ax.fill_between(x=[0, len(feature_weights_train) - bar_width], 
                       y1=[price_corr_matrix[0][0] for _ in range(len(feature_weights_train) - bar_width)],
                       y2=[price_corr_matrix[len(feature_weights_train) - bar_width][0] for _ in range(len(feature_weights_train) - bar_width)],
                       facecolor="skyblue",
                       edgecolor=".5",
                       linewidth=0.5)
      
      # 最后添加背景颜色和阴影效果
      ax.get_figure().set_facecolor("white")
      ax.get_figure().set_edgecolor("black")
      
      # 显示图表
      plt.show()
      

      请注意,这个示例代码使用了一个简单的柱状图,并未考虑潜在的异常情况(如缺失特征或特征值变化不一致)或数值特征的范围限制(如正负数)。如果您想要处理更复杂的情况,可能需要添加更多的数据预处理步骤,如归一化特征值、进行特征工程、进行异常检测等。此外,您也可以选择使用其他图形库(如 Matplotlib, Seaborn 等)或 API 来实现实时绘制图,这些工具提供了更多灵活的可视化功能和模型调优选项。

      展开全部

      评论 编辑记录
    • sto。9 2024-04-01 21:46
      关注

      我也是这个问题,前几天用还好好的,今天就出错了,创建文件夹可以,就是在网站上打不开,一直显示2024/4/1/……port.cc:113 】oneDNN custom operations are on

      评论
    编辑
    预览

    报告相同问题?

  • 相关阅读:
    java 企业工程管理系统软件源码+Spring Cloud + Spring Boot +二次开发+ MybatisPlus + Redis
    做期货的阶段(做期货的几个阶段)
    node exec(“clip“) 复制到剪切板 乱码
    关于使用Linkage mapper 构建生态网络的数据说明
    qemu的详细资料大全(入门必看!!!)
    CANoe制作网关实现CAN(FD)报文故障注入(报文长度/timeout/信号错误/E2E)1
    C++内存管理
    机器学习笔记之线性回归——从概率密度函数角度认识最小二乘法
    mkfs.ubifs与ubinize
    如何在vuejs项目中使用md5加密密码
  • 原文地址:https://ask.csdn.net/questions/8080812