相关疑难解决方法(0)

InvalidArgumentError :您必须使用 dtype float 为占位符张量“Placeholder”提供一个值

我在 Jupyter Notebook 中编写了以下代码,它在 Tensorflow 中执行线性回归:

import tensorflow as tf
import numpy as np
import pandas as pd
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt

boston=load_boston()
type(boston)
boston.feature_names

bd=pd.DataFrame(data=boston.data,columns=boston.feature_names)

bd['Price']=pd.DataFrame(data=boston.target)
np.random.shuffle(bd.values)


W0=tf.Variable(0.0000000000003)
W1=tf.Variable(0.000000000002)
b=tf.Variable(0.0000000000001)
    #print(bd.shape[1])

tf.summary.histogram('Weights', W0)
tf.summary.histogram('Weights', W1)
tf.summary.histogram('Biases', b)



dataset_input=bd.iloc[:, 0 : bd.shape[1]-1];
    #dataset_input.head(2)

dataset_output=bd.iloc[:, bd.shape[1]-1]
dataset_output=dataset_output.values
dataset_output=dataset_output.reshape((bd.shape[0],1)) #converted (506,) to (506,1) because in pandas
    #the shape was not changing and it was needed later in feed_dict


dataset_input=dataset_input.values  #only dataset_input is in DataFrame form and converting it …
Run Code Online (Sandbox Code Playgroud)

python-3.x tensorflow

0
推荐指数
1
解决办法
4672
查看次数

标签 统计

python-3.x ×1

tensorflow ×1