学习中遇到的问题记录

最近在学tensorflow,教学中使用的时tensorflow1.x版本,我用的最新的tensorflow2.14。从安装到现在起步学习都遇到了问题,安装GPU版本时发现安装不了。

学习设备为19年戴尔灵越笔记本,1050显卡,CPUi5-9300H ,24G内存,(初始为8G,自己装了一个16G的)。运行环境为python3.9.13,pycharm2021.3,tensorflow2.14.

以下为安装GPU版本时显示的错误,不知道是不是显卡问题安装不上GPU版本,另外搜索后看到推荐用anaconda可以帮你配环境,并没有尝试。

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for tensorflow-gpu
ERROR: Could not build wheels for tensorflow-gpu, which is required to install pyproject.toml-based projects

无奈安装了普通版本。

接下来跟着学习视频操作,这是遇到的第一个问题

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import  numpy as np

#crear data
x_data = np.random.rand(100).astype(np.float32)
y_data = x_data*.01+0.3

#creare tensorflow structure start ###
Weights = tf.Variable(tf.random_uniform([1],-1.0,1.0))
biases = tf.Variable(tf.zeros([1]))

y = Weights*x_data + biases

loss = tf.reduce_mean(tf.square(y-y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)

init = tf.initialize_all_variables()

#creare tensorflow structure end ###

sess =tf.Session()
sess.run(init)        #Very iportant

for step in range(201):
    sess.run(train)
    if step %20 == 0:
        print(step,sess.run(Weights),sess.run(biases))

原视频代码import tensorflow as tf会报错,看评论知道改为现在的最上面两行,但是神奇的是,它提示任然出错,但是却可以运行。搞不懂。

WARNING:tensorflow:From C:\Users\11730\PycharmProjects\pythonProject1\venv\lib\site-packages\tensorflow\python\compat\v2_compat.py:108: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
WARNING:tensorflow:From C:\Users\11730\PycharmProjects\pythonProject1\venv\lib\site-packages\tensorflow\python\util\tf_should_use.py:288: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.
2023-11-02 17:24:39.592671: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-11-02 17:24:39.594938: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:382] MLIR V1 optimization pass is not enabled

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值