Python-初学tensorflow第二天-学习例子

学习来源Bilibili 根据例子编写出线性回归方程 import tensorflow as tf import pandas as pd data=pd.read_csv('./demo1.csv') x=data.Education y=data.Income model=tf.keras.Sequential(()) model.add(tf.keras.layers.Dense(1,input_shape=(1,))) model.compile(optimizer='adam',loss='mse') history=model.fit(x,y,epochs=10000) res=model.predict(pd.Series([20])) print(res) ,Education,Income 1,10.000000 ,26.658839 2,10.401338 ,27.306435 3,10.842809 ,22.132410 4,11.244147 ,21.169841 5,11.645449 ,15.192634 6,12.086957 ,26.398951 7,12.048829 ,17.435307 8,12.889632 ,25.507885 9,13.290970 ,36.884595 10,13.732441 ,39.666109 11,14.133779 ,34.396281 12,14.635117 ,41.497994 13,14.978589 ,44.981575 14,15.377926 ,47.039595 15,15.779264 ,48.252578 16,16.220736 ,57.034251 17,16.622074 ,51.490919 18,17.023411 ,51.336621 19,17.464883 ,57.681998 20,17.866221 ,68.553714 21,18.267559 ,64.310925 22,18.709030 ,68.959009 23,19.110368 ,74.614639 24,19.511706 ,71.867195 25,19.913043 ,76.098135...

八月 12, 2022 · 1 分钟 · Ken

Python-初学tensorflow第一天-搭建环境

初学第一天主要学习如果搭建环境和快捷安装TensorFlow的扩展 打开miniconda官网 选择合适自己的系统来安装python环境 安装TensorFlow扩展 : pip install tensorflow==2.8.0 可能pip版本不够导致安装失败 easy_install -U pip 安装其他所需的包: pip install pandas matplotlib nodebook pandas 数据分析库 matplotlib python绘图库 nodebook 基于web的开发环境 安装cuda 安装pytorch Q: 运行失败时返回 Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found A: 在截图中找到相应的版本后,打开 nvidia Q: 安装cuda失败时返回 you already have a newer version of the nvdia frameview sdk installed A: 找到C:\Program Files\NVIDIA Corporation\FrameViewSDK文件夹进行卸载 Q: 安装cuda一直安装不成功,nsight visual studio edition提示安装失败 A: 尝试卸载电脑的Visual Studio Community Q: Downgrade the protobuf package to 3....

八月 12, 2022 · 1 分钟 · Ken