No matter how I change my model, there always a error happens
# import os
# import numpy as np
#
# from utils import read
# from DenseNet import ConvDense, DenseBlock
# from Loss import CombinedLoss
import tensorflow as tf
def train():
# path_list = [os.path.join('train-for-densenet', path) for path in os.listdir('train-for-densenet')]
# print(type(path_list))
# path_dataset = tf.data.Dataset.from_tensor_slices(path_list)
# print(path_dataset)
# dataset = path_dataset.map(lambda path: read(path)).take(10)
# for e in dataset:
# e = tf.ones([256, 256, 1], dtype=tf.float32)
# print(e)
# print(dataset.batch(2))
dataset = tf.ones([10, 256, 256, 1], dtype=tf.float32)
dataset = tf.data.Dataset.from_tensor_slices(dataset)
for e in dataset:
print(e)
print(dataset)
model = tf.keras.models.Sequential([
# tf.keras.layers.Rescaling(1. / 255),
# ConvDense(16),
# DenseBlock(),
# ConvDense(64),
# ConvDense(32),
# ConvDense(16),
# ConvDense(1),
tf.keras.layers.Dense(10, activation='sigmoid')
])
# combined_loss = CombinedLoss(weight_ssim=0.7)
model.compile(
optimizer='Adam',
loss=tf.keras.losses.CategoricalCrossentropy
)
# model.build(input_shape=(None, 256, 256, 1))
try:
model.fit(
dataset,
epochs=4
)
except Exception as e:
print("Error:", e)
print(model.summary())
if __name__ == '__main__':
train()
I customize my model and try to train it but find this error. I think that my model have some problems, but it still has same error after I use Sequtial model with keras.layers.