Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python as_list()未在未知的张量形状上定义_Python_Tensorflow_Machine Learning_Tensorflow Datasets_Tfrecord - Fatal编程技术网

Python as_list()未在未知的张量形状上定义

Python as_list()未在未知的张量形状上定义,python,tensorflow,machine-learning,tensorflow-datasets,tfrecord,Python,Tensorflow,Machine Learning,Tensorflow Datasets,Tfrecord,**更新 在实现@jdehesa后,回答:我的代码如下所示: from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import os import PIL as pil from tensorflow import feature_c

**更新 在实现@jdehesa后,回答:我的代码如下所示:

from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf

import numpy as np
import matplotlib.pyplot as plt
import os
import PIL as pil
from tensorflow import feature_column
from tensorflow_core.python.platform.flags import FLAGS

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'


def print_type(name , x):
    print(" {} type = {}".format(name, type(x)))


def _bytes_feature(value):
    """Returns a bytes_list from a string / byte."""
    if isinstance(value, type(tf.constant(0))):
        value = value.numpy() # BytesList won't unpack a string from an EagerTensor.
    return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))


def _float_feature(value):
    if not isinstance(value, np.ndarray):
        value = [value]
    """Returns a float_list from a float / double."""
    return tf.train.Feature(float_list=tf.train.FloatList(value=value))


def _int64_feature(value):
    """Returns an int64_list from a bool / enum / int / uint."""
    if not isinstance(value, np.ndarray):
        value = [value]
    return tf.train.Feature(int64_list=tf.train.Int64List(value=value))


def encode_example(arr, label):
    shape = arr.shape
    feature = {
        'height': _int64_feature(shape[0]),
        'width': _int64_feature(shape[1]),
        'label': _int64_feature(label),
        'image_raw': _bytes_feature(arr.flatten().tobytes()),
    }
    # print("Encoding type {}".format(type(feature['image_raw'])))
    return tf.train.Example(features=tf.train.Features(feature=feature))


def decode_example(serialized_example):
    # Create a dictionary describing the features.
    image_feature_description = {
        'height': tf.io.FixedLenFeature([], tf.int64),
        'width': tf.io.FixedLenFeature([], tf.int64),
        'label': tf.io.FixedLenFeature([], tf.int64),
        'image_raw': tf.io.FixedLenFeature([], tf.string),
    }
    example = tf.io.parse_single_example(serialized_example, image_feature_description)
    return example


def map_example(height, width, image_raw, label):
    # Assumes little endian decoding, pass little_endian=False for big endian
    image_data = tf.io.decode_raw(image_raw, tf.uint8)
    image_data = tf.reshape(image_data, [height, width])
    return image_data, label



def make_dataset(partition):
    files = tf.data.Dataset.list_files("images_" + partition + "*.tfrecord")
    dataset = tf.data.TFRecordDataset(files)
    # dataset = dataset.shuffle(buffer_size=FLAGS.shuffle_buffer_size)
    dataset = dataset.map(decode_example)
    dataset = dataset.map(
        lambda x: map_example(x['height'], x['width'], x['image_raw'], x['label']))
    # dataset = dataset.batch(batch_size=FLAGS.batch_size)
    return dataset



def write_examples_to_record_file(file_name, x , y):
    with tf.io.TFRecordWriter(file_name) as writer:
        for i in range(len(x)):
            tf_example = encode_example(x[i], y[i])
            writer.write(tf_example.SerializeToString())


mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, y_train, x_test, y_test = x_train[:100], y_train[:100], x_test[:100], y_test[:100]
# x_train, x_test = x_train.astype(np.int8), x_test.astype(np.int8)

write_examples_to_record_file('images_train.tfrecord', x_train, y_train)
# write_examples_to_record_file('images_test.tfrecord', x_test, y_test)
train_dataset = make_dataset("train")
# test_dataset = make_dataset("test")

it = iter(train_dataset)
r = next(it)
print_type("r",r)
(x,y) = r
print_type("X", x)
print_type("Y", y)
print("x is" , x)
print("y is" , y)
print("x shape is" , x.shape())
print("y shape is" , y.shape())
# print(next(it))

# for r,label in next(it):
#     print(repr(r))
#     print("feature shape = {}".format(r.shape.as_list()))
#     print("label shape = {}".format(label.shape.as_list()))


# feature_column = [tf.feature_column.numeric_column(key='image', shape=(28,28))]
# feature_layer = tf.keras.layers.DenseFeatures(feature_column)
#

# it = iter(train_dataset)
model = tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=[28,28]),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(train_dataset,  epochs=5)
# model.evaluate(test_dataset, verbose=2)
但现在错误不同了,我认为这是原始问题错误的原因,即获取next()元组的x,y分量的形状有问题:

在开始训练之前,我发现了以下错误,你知道为什么它不起作用吗

2019-11-19 06:31:21.067987: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found
2019-11-19 06:31:23.315270: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2019-11-19 06:31:23.315617: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2019-11-19 06:31:23.320751: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: szclu-dvcasa027
2019-11-19 06:31:23.321132: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: szclu-dvcasa027
2019-11-19 06:31:23.321927: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:Entity <function decode_example at 0x00000250EE94A1F8> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: No module named 'tensorflow_core.estimator'
WARNING:tensorflow:Entity <function make_dataset.<locals>.<lambda> at 0x00000250EE94A438> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: No module named 'tensorflow_core.estimator'
feature shape = [28, 28]
label shape = [1]
Epoch 1/5
Traceback (most recent call last):
  File "C:/data/projects/cludeeplearning/train_model.py", line 110, in <module>
    model.fit(train_dataset,  epochs=5)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 728, in fit

      1/Unknown - 0s 13ms/step
      1/Unknown - 0s 13ms/step    use_multiprocessing=use_multiprocessing)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 324, in fit
    total_epochs=epochs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 123, in run_one_epoch
    batch_outs = execution_function(iterator)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 86, in execution_function
    distributed_function(input_fn))
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 457, in __call__
    result = self._call(*args, **kwds)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 503, in _call
    self._initialize(args, kwds, add_initializers_to=initializer_map)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 408, in _initialize
    *args, **kwds))
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\function.py", line 1848, in _get_concrete_function_internal_garbage_collected
    graph_function, _, _ = self._maybe_define_function(args, kwargs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\function.py", line 2150, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\function.py", line 2041, in _create_graph_function
    capture_by_value=self._capture_by_value),
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\framework\func_graph.py", line 915, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 358, in wrapped_fn
    return weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 66, in distributed_function
    model, input_iterator, mode)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 112, in _prepare_feed_values
    inputs, targets, sample_weights = _get_input_from_iterator(inputs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 149, in _get_input_from_iterator
    distribution_strategy_context.get_strategy(), x, y, sample_weights)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\distribute\distributed_training_utils.py", line 308, in validate_distributed_dataset_inputs
    x_values_list = validate_per_replica_inputs(distribution_strategy, x)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\distribute\distributed_training_utils.py", line 356, in validate_per_replica_inputs
    validate_all_tensor_shapes(x, x_values)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\distribute\distributed_training_utils.py", line 373, in validate_all_tensor_shapes
    x_shape = x_values[0].shape.as_list()
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 1171, in as_list
    raise ValueError("as_list() is not defined on an unknown TensorShape.")
ValueError: as_list() is not defined on an unknown TensorShape.

Process finished with exit code 1
2019-11-19 06:31:21.067987:W tensorflow/stream_executor/platform/default/dso_loader.cc:55]无法加载动态库“cudart64_100.dll”;错误:找不到cudart64_100.dll
2019-11-19 06:31:23.315270:W tensorflow/stream_executor/platform/default/dso_loader.cc:55]无法加载动态库“nvcuda.dll”;错误:未找到nvcuda.dll
2019-11-19 06:31:23.315617:E tensorflow/stream_executor/cuda/cuda_driver.cc:318]调用cuInit失败:未知错误(303)
2019-11-19 06:31:23.320751:I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169]检索主机的cuda诊断信息:szclu-dvcasa027
2019-11-19 06:31:23.321132:I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176]主机名:szclu-dvcasa027
2019-11-19 06:31:23.321927:I tensorflow/core/platform/cpu\u feature\u guard.cc:142]您的cpu支持该tensorflow二进制文件未编译为使用的指令:AVX2
警告:tensorflow:无法转换实体,将按原样执行。请向签名组报告。在归档bug时,将详细度设置为10(在Linux上,`export AUTOGRAPH\u verbosity=10`),并附加完整的输出。原因:没有名为“tensorflow_core.estimator”的模块
警告:tensorflow:无法转换实体,将按原样执行。请向签名组报告。在归档bug时,将详细度设置为10(在Linux上,`export AUTOGRAPH\u verbosity=10`),并附加完整的输出。原因:没有名为“tensorflow_core.estimator”的模块
特征形状=[28,28]
标签形状=[1]
纪元1/5
回溯(最近一次呼叫最后一次):
文件“C:/data/projects/cludeeptlearning/train_model.py”,第110行,在
model.fit(train_数据集,历元=5)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training.py”,第728行
1/未知-0秒13毫秒/步
1/未知-0s 13ms/步使用\多处理=使用\多处理)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training\u v2.py”,第324行
总(单位时间=时间)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training\u v2.py”,第123行,run\u one\u
批处理输出=执行函数(迭代器)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training\u v2\u utils.py”,第86行,执行函数
分布函数(输入函数)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\def\u function.py”,第457行,在调用中__
结果=自身调用(*args,**kwds)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\def\u function.py”,第503行,在调用中
self.\u initialize(args、kwds、add\u initializer\u to=initializer\u map)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\def\u function.py”,第408行,在\u initialize中
*args,**科威特第纳尔)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\function.py”,第1848行,位于“get\u concrete\u function\u internal\u garbage\u collected”中
图函数,自我,可能定义函数(args,kwargs)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\function.py”,第2150行,在定义函数中
graph\u function=self.\u create\u graph\u function(args,kwargs)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\function.py”,第2041行,在创建图函数中
按值捕获=自身。_按值捕获),
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\framework\func\u graph.py”,第915行,在函数图中
func_outputs=python_func(*func_args,**func_kwargs)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\eager\def\u function.py”,第358行,包装为\u fn
返回弱_-wrapped_-fn()
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training\u v2\u utils.py”,第66行,在分布式函数中
模型,输入(迭代器,模式)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training\u v2\u utils.py”,第112行,在\u prepare\u feed\u值中
输入、目标、样本权重=\u从\u迭代器获取\u输入(输入)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\engine\training\u v2\u utils.py”,第149行,从迭代器获取输入
分布策略上下文。获取策略(),x,y,样本权重)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\distribute\distributed\u training\u utils.py”,第308行,在验证分布式数据集输入中
x_值_列表=验证每个副本的输入(分发策略,x)
文件“C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site packages\tensorflow\u core\python\keras\distribute\distributed\u training\u utils.py”,第356行,在每个副本的验证输入中
验证所有张量形状
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf

import numpy as np
import matplotlib.pyplot as plt
import os
import PIL as pil
from tensorflow import feature_column
from tensorflow_core.python.platform.flags import FLAGS

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'


def _bytes_feature(value):
    """Returns a bytes_list from a string / byte."""
    if isinstance(value, type(tf.constant(0))):
        value = value.numpy() # BytesList won't unpack a string from an EagerTensor.
    return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))


def _float_feature(value):
    if not isinstance(value, np.ndarray):
        value = [value]
    """Returns a float_list from a float / double."""
    return tf.train.Feature(float_list=tf.train.FloatList(value=value))


def _int64_feature(value):
    """Returns an int64_list from a bool / enum / int / uint."""
    if not isinstance(value, np.ndarray):
        value = [value]
    return tf.train.Feature(int64_list=tf.train.Int64List(value=value))


def encode_example(arr, label):
    shape = arr.shape

    feature = {
        'height': _int64_feature(shape[0]),
        'width': _int64_feature(shape[1]),
        'label': _int64_feature(label),
        'image_raw': _bytes_feature(arr.flatten().tobytes()),
    }
    # print("Encoding type {}".format(type(feature['image_raw'])))
    return tf.train.Example(features=tf.train.Features(feature=feature))


def decode_example(serialized_example):
    # Create a dictionary describing the features.
    image_feature_description = {
        'height': tf.io.FixedLenFeature([], tf.int64),
        'width': tf.io.FixedLenFeature([], tf.int64),
        'label': tf.io.FixedLenFeature([], tf.int64),
        'image_raw': tf.io.FixedLenFeature([], tf.string),
    }
    example = tf.io.parse_single_example(serialized_example, image_feature_description)
    return example


def map_example(height, width, image_raw, label):
    image_data = np.frombuffer(image_raw.numpy(), dtype=np.dtype('int64'))
    image_data = tf.reshape(image_data, [height.numpy(), width.numpy()])
    # image_data.set_shape([28,28])
    label = tf.constant([label.numpy()], tf.int64)
    return image_data, label


def make_dataset(partition):
    files = tf.data.Dataset.list_files("images_" + partition + "*.tfrecord")
    dataset = tf.data.TFRecordDataset(files)
    # dataset = dataset.shuffle(buffer_size=FLAGS.shuffle_buffer_size)
    dataset = dataset.map(decode_example)
    dataset = dataset.map(lambda x: tf.py_function(func=map_example, inp=[x['height'], x['width'], x['image_raw'], x['label']], Tout=(tf.int64, tf.int64)))
    # dataset = dataset.batch(batch_size=FLAGS.batch_size)
    return dataset


def write_examples_to_record_file(file_name, x , y):
    with tf.io.TFRecordWriter(file_name) as writer:
        for i in range(len(x)):
            tf_example = encode_example(x[i], y[i])
            writer.write(tf_example.SerializeToString())


mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, y_train, x_test, y_test = x_train[:100], y_train[:100], x_test[:100], y_test[:100]
x_train, x_test = x_train / 255.0, x_test / 255.0
write_examples_to_record_file('images_train.tfrecord', x_train, y_train)
# write_examples_to_record_file('images_test.tfrecord', x_test, y_test)
train_dataset = make_dataset("train")
# test_dataset = make_dataset("test")

for r in train_dataset.take(1):
    print(r[0].shape.as_list())
    print(r[1])


# feature_column = [tf.feature_column.numeric_column(key='image', shape=(28,28))]
# feature_layer = tf.keras.layers.DenseFeatures(feature_column)
#
model = tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=[28,28,1]),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(train_dataset,  epochs=5)
# model.evaluate(test_dataset, verbose=2)
2019-11-19 06:31:21.067987: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found
2019-11-19 06:31:23.315270: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2019-11-19 06:31:23.315617: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2019-11-19 06:31:23.320751: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: szclu-dvcasa027
2019-11-19 06:31:23.321132: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: szclu-dvcasa027
2019-11-19 06:31:23.321927: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:Entity <function decode_example at 0x00000250EE94A1F8> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: No module named 'tensorflow_core.estimator'
WARNING:tensorflow:Entity <function make_dataset.<locals>.<lambda> at 0x00000250EE94A438> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: No module named 'tensorflow_core.estimator'
feature shape = [28, 28]
label shape = [1]
Epoch 1/5
Traceback (most recent call last):
  File "C:/data/projects/cludeeplearning/train_model.py", line 110, in <module>
    model.fit(train_dataset,  epochs=5)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 728, in fit

      1/Unknown - 0s 13ms/step
      1/Unknown - 0s 13ms/step    use_multiprocessing=use_multiprocessing)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 324, in fit
    total_epochs=epochs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 123, in run_one_epoch
    batch_outs = execution_function(iterator)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 86, in execution_function
    distributed_function(input_fn))
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 457, in __call__
    result = self._call(*args, **kwds)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 503, in _call
    self._initialize(args, kwds, add_initializers_to=initializer_map)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 408, in _initialize
    *args, **kwds))
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\function.py", line 1848, in _get_concrete_function_internal_garbage_collected
    graph_function, _, _ = self._maybe_define_function(args, kwargs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\function.py", line 2150, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\function.py", line 2041, in _create_graph_function
    capture_by_value=self._capture_by_value),
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\framework\func_graph.py", line 915, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 358, in wrapped_fn
    return weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 66, in distributed_function
    model, input_iterator, mode)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 112, in _prepare_feed_values
    inputs, targets, sample_weights = _get_input_from_iterator(inputs)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 149, in _get_input_from_iterator
    distribution_strategy_context.get_strategy(), x, y, sample_weights)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\distribute\distributed_training_utils.py", line 308, in validate_distributed_dataset_inputs
    x_values_list = validate_per_replica_inputs(distribution_strategy, x)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\distribute\distributed_training_utils.py", line 356, in validate_per_replica_inputs
    validate_all_tensor_shapes(x, x_values)
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\keras\distribute\distributed_training_utils.py", line 373, in validate_all_tensor_shapes
    x_shape = x_values[0].shape.as_list()
  File "C:\Users\me\AppData\Local\Continuum\anaconda3\envs\deeplearning\lib\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 1171, in as_list
    raise ValueError("as_list() is not defined on an unknown TensorShape.")
ValueError: as_list() is not defined on an unknown TensorShape.

Process finished with exit code 1
def map_example(height, width, image_raw, label):
    image_data = tf.io.decode_raw(image_raw, tf.uint8)
    image_data = tf.reshape(image_data, [1, height, width])
    return image_data, label

def make_dataset(partition):
    files = tf.data.Dataset.list_files("images_" + partition + "*.tfrecord")
    dataset = tf.data.TFRecordDataset(files)
    # dataset = dataset.shuffle(buffer_size=FLAGS.shuffle_buffer_size)
    dataset = dataset.map(decode_example)
    dataset = dataset.map(
        lambda x: map_example(x['height'], x['width'], x['image_raw'], x['label']))
    # dataset = dataset.batch(batch_size=FLAGS.batch_size)
    return dataset