小编jig*_*gar的帖子

在 Tensorflow 2.2.0 中,在将数据与validation_data一起拟合后,我的 model.history.history 为空

起初它工作正常,然后我尝试在创建模型时调整一些参数,之后,

print(model.history.history)
Run Code Online (Sandbox Code Playgroud)

给了我一本空字典。

这是我的完整代码(如果有帮助的话)

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from sklearn.metrics import mean_absolute_error

df = pd.read_csv('TF_2_Notebooks_and_Data/DATA/kc_house_data.csv')
# print(df.columns)
'''prints
Index(['id', 'date', 'price', 'bedrooms', 'bathrooms', 'sqft_living',
       'sqft_lot', 'floors', 'waterfront', 'view', 'condition', 'grade',
       'sqft_above', 'sqft_basement', 'yr_built', 'yr_renovated', 'zipcode',
       'lat', 'long', 'sqft_living15', 'sqft_lot15'],
      dtype='object')'''
# if we want to see what data column has missing data …
Run Code Online (Sandbox Code Playgroud)

python dataframe pandas keras tensorflow

6
推荐指数
1
解决办法
5793
查看次数

无法解决,最终确定 GeneratorDataset 迭代器时发生错误:失败的前提条件:Python 解释器状态未初始化

无法解决此错误:

tensorflow.python.framework.errors_impl.InvalidArgumentError:  logits and labels must have the same first dimension, got logits shape [4,1] and labels shape [12]
     [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at /Users/astro/pythonprojects/covid_chest_xray_image_classification/main.py:86) ]] [Op:__inference_train_function_978]

Function call stack:
train_function

2020-07-17 01:50:11.552216: W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.
     [[{{node PyFunc}}]]

Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)

我正在尝试根据三个类别对图像进行分类,

如果有帮助,这是我的代码:

# Classification of cases from Chest-xray images
import os
import numpy as np
import matplotlib.pyplot as plt …
Run Code Online (Sandbox Code Playgroud)

python python-3.x conv-neural-network tensorflow tensorflow2.0

5
推荐指数
1
解决办法
1万
查看次数