Layer “model” expects 2 input(s), but it received 1 input tensors. Inputs rec: []

`I am upgrading tensorflow 2.4.1 with 2.15.0. I am re-using the model trained with 2.4.1. I am unable to do batch-wise prediction int he upgraded version. The input format is taken as 1 tensor.
Model input shape: [(None, 46, 1), (None, 46, 1)]
Batch data shapes: [(200, 46, 1), (200, 46, 1)]

Model summary is identical in both versions.

import tensorflow as tf
import numpy as np

class predictDataGenerator(tf.keras.utils.Sequence):
    'Generates data for Keras'
    def __init__(self, inData, nsamps, batch_size=250, dim=46,
                 n_channels=1, inData_ch2=None, n_classes=2,
                 avg_num=3, befN=18, shuffle=True):
        'Initialization'
        self.dim = dim
        self.batch_size = batch_size
        self.inData = inData
        self.inData_ch2 = inData_ch2
        self.n_channels = n_channels
        self.n_classes = n_classes
        self.avg_num = avg_num
        self.befN = befN
        self.part_start = (self.befN + 1) * self.avg_num + self.avg_num // 2 - (self.befN + 1)
        self.part_window = self.dim + 1
        self.obj_window = (self.dim + 1) * self.avg_num
        self.part_tile = np.tile(np.arange(self.dim), (self.batch_size, 1))
        self.part_tile += np.arange(self.batch_size).reshape(self.batch_size, 1)
        self.shuffle = shuffle
        self.nsamps = nsamps
        self.on_epoch_end()
        self.batch_count = self.__len__()

    def __len__(self):
        'Denotes the number of batches per epoch'
        return int(np.ceil(self.nsamps / self.batch_size))

    def __getitem__(self, index):
        'Generate one batch of data'
        # Generate indexes of the batch
        batch_data = self.inData[index * self.batch_size:(index + 1) * self.batch_size + self.obj_window - 1]
        num_points = batch_data.size - (self.obj_window - 1)
        X_OBJ = np.empty((num_points, self.dim, self.n_channels))
        X_PART = np.empty((num_points, self.dim, self.n_channels))
        for i in range(self.n_channels):
            X_obj, X_part = self.__data_generation(batch_data, num_points)
            X_PART[:, :, i] = X_part
            X_OBJ[:, :, i] = X_obj
        return (X_OBJ, X_PART)

    def on_epoch_end(self):
        'Updates indexes after each epoch'
        # Optional: Implement shuffling if needed
        if self.shuffle:
            self.indexes = np.arange(self.nsamps)
            np.random.shuffle(self.indexes)

    def get_part_data(self, batch_data, num_points):
        'Prepare part data'
        part_end = self.part_start + num_points + self.part_window
        temp_data = batch_data[self.part_start:part_end]  # Required samples
        temp_data = np.diff(temp_data)  # temp_data[1:] - temp_data[:-1]
        X_part2 = temp_data[self.part_tile[:num_points, :]]
        return X_part2

    def get_obj_data(self, batch_data, num_points):
        'Prepare object data'
        X_OBJ2 = np.empty((num_points, self.dim))
        for i in range(self.avg_num):
            temp_end = batch_data.size - (batch_data.size - i) % self.avg_num
            temp_data = batch_data[i:temp_end]
            temp_data = temp_data.reshape(-1, self.avg_num)
            temp_data = np.sum(temp_data, axis=1) / self.avg_num
            temp_data = np.diff(temp_data)
            num_windows = temp_data.size - self.dim + 1
            obj_tile = np.tile(np.arange(self.dim), (num_windows, 1))
            obj_tile += np.arange(num_windows).reshape(num_windows, 1)
            X_OBJ2[i::self.avg_num] = temp_data[obj_tile]
        return X_OBJ2

    def __data_generation(self, batch_data, num_points):
        'Generates data for one batch'
        X_part = self.get_part_data(batch_data, num_points)
        X_obj = self.get_obj_data(batch_data, num_points)
        X_part = X_part - np.mean(X_part, axis=1).reshape(-1, 1)
        X_part = X_part / ((np.std(X_part, axis=1)).reshape(-1, 1) + 1e-100)
        X_obj = X_obj - np.mean(X_obj, axis=1).reshape(-1, 1)
        X_obj = X_obj / ((np.std(X_obj, axis=1)).reshape(-1, 1) + 1e-100)
        return X_obj, X_part

X_test = np.arange(1140)
pred_length = X_test.size-l_start-l_end
bsize = 200 

testgen = predictDataGenerator(X_test.reshape(-1),
                    pred_length,batch_size=bsize,dim = Window,
                    avg_num = avgN,
                    befN = window1,shuffle=False)
print(len(testgen))
probs = bd_model.predict(testgen)

ERROR:

ValueError: Layer “model” expects 2 input(s), but it received 1 input tensors. Inputs received: [<tf.Tensor ‘IteratorGetNext:0’ shape=(None, None, None) dtype=float32>]`

New contributor

Pavitra Bijoy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật