src/utils.py
def reshape_patch(img_tensor, patch_size):
    """Reshape a 5D image tensor to a 5D patch tensor."""
    # print(f"adasd {np.shape(img_tensor)}")
    # assert 5 == img_tensor.ndim
    batch_size = np.shape(img_tensor)[0]
    seq_length = np.shape(img_tensor)[1]
    img_height = np.shape(img_tensor)[2]
    img_width = np.shape(img_tensor)[3]
    num_channels = np.shape(img_tensor)[4]
    a = np.reshape(img_tensor, [
        batch_size, seq_length, img_height // patch_size, patch_size,
                                img_width // patch_size, patch_size, num_channels
    ])
    b = np.transpose(a, [0, 1, 2, 4, 3, 5, 6])
    patch_tensor = np.reshape(b, [
        batch_size, seq_length, img_height // patch_size, img_width // patch_size,
                                patch_size * patch_size * num_channels
    ])
    return patch_tensor
Reshape a 5D image tensor to a 5D patch tensor.
Reshape a 5D image tensor to a 5D patch tensor.
Reshape a 5D image tensor to a 5D patch tensor .
def reshape_patch(img_tensor, patch_size):
    batch_size = np.shape(img_tensor)[0]
    seq_length = np.shape(img_tensor)[1]
    img_height = np.shape(img_tensor)[2]
    img_width = np.shape(img_tensor)[3]
    num_channels = np.shape(img_tensor)[4]
    a = np.reshape(img_tensor, [
        batch_size, seq_length, img_height // patch_size, patch_size,
                                img_width // patch_size, patch_size, num_channels
    ])
    b = np.transpose(a, [0, 1, 2, 4, 3, 5, 6])
    patch_tensor = np.reshape(b, [
        batch_size, seq_length, img_height // patch_size, img_width // patch_size,
                                patch_size * patch_size * num_channels
    ])
    return patch_tensor
def reshape_patch ( img_tensor , patch_size ) : batch_size = np . shape ( img_tensor ) [ 0 ] seq_length = np . shape ( img_tensor ) [ 1 ] img_height = np . shape ( img_tensor ) [ 2 ] img_width = np . shape ( img_tensor ) [ 3 ] num_channels = np . shape ( img_tensor ) [ 4 ] a = np . reshape ( img_tensor , [ batch_size , seq_length , img_height // patch_size , patch_size , img_width // patch_size , patch_size , num_channels ] ) b = np . transpose ( a , [ 0 , 1 , 2 , 4 , 3 , 5 , 6 ] ) patch_tensor = np . reshape ( b , [ batch_size , seq_length , img_height // patch_size , img_width // patch_size , patch_size * patch_size * num_channels ] ) return patch_tensor
Reshape a 5D image tensor to a 5D patch tensor.
Reshape a 5D image tensor to a 5D patch tensor .
"""Reshape a 5D image tensor to a 5D patch tensor.""" # print(f"adasd {np.shape(img_tensor)}") # assert 5 == img_tensor.ndim
img_tensor
patch_size