示例#1
0
def test_fpccn_decompress():
    """Test the FPCNN class decompression function."""

    data_shape = (8, 8, 8)  # x, y, lambda
    hyperparams = {
        "track_spatial_length":
        1,
        "track_spatial_width":
        5,
        "track_spectral_length":
        1,
        "track_spectral_width":
        5,
        "track_fusion_length":
        1,
        "track_fusion_width":
        5,
        "lr":
        0.01,
        "context_offsets_spatial": [
            (-1, 0, 0),
            (-1, -1, 0),
            (0, -1, 0),
            (1, -1, 0),
            (-1, 0, -1),
            (-1, -1, -1),
            (0, -1, -1),
            (1, -1, -1),
            (-1, 0, -2),
            (-1, -1, -2),
            (0, -1, -2),
            (1, -1, -2),
        ],
        "context_offsets_spectral": [(0, 0, -1), (0, 0, -2), (0, 0, -3),
                                     (0, 0, -4)],
    }

    rng = np.random.default_rng()

    data = rng.integers(low=0, high=16383, size=data_shape)
    LOG.info(f"Data ({data.shape}, {data.dtype}):\n{data}")

    model = models.FPCNN(hp=hyperparams, logname="test_decompress_toy")

    output = model.decompress(data=data)
    LOG.info(f"Output ({output.shape}, {output.dtype}):\n{output}")
示例#2
0
文件: gym.py 项目: DM1122/fpcnn
    def _build_model(self, params):
        LOG.debug("Building model")
        model = models.FPCNN(
            hp={
                "track_spatial_length":
                1,
                "track_spatial_width":
                5,
                "track_spectral_length":
                1,
                "track_spectral_width":
                5,
                "track_fusion_length":
                1,
                "track_fusion_width":
                5,
                "lr":
                0.01,
                "context_offsets_spatial": [
                    (-1, 0, 0),
                    (-1, -1, 0),
                    (0, -1, 0),
                    (1, -1, 0),
                    (-1, 0, -1),
                    (-1, -1, -1),
                    (0, -1, -1),
                    (1, -1, -1),
                    (-1, 0, -2),
                    (-1, -1, -2),
                    (0, -1, -2),
                    (1, -1, -2),
                ],
                "context_offsets_spectral": [
                    (0, 0, -1),
                    (0, 0, -2),
                    (0, 0, -3),
                    (0, 0, -4),
                ],
            },
            logname="tuning_ip",
        )

        return model
示例#3
0
def test_fpcnn_instantiate_model():
    """Test the FPCNN class model instantiation method."""

    hyperparams = {
        "track_spatial_length":
        1,
        "track_spatial_width":
        5,
        "track_spectral_length":
        1,
        "track_spectral_width":
        5,
        "track_fusion_length":
        1,
        "track_fusion_width":
        5,
        "lr":
        0.01,
        "context_offsets_spatial": [
            (-1, 0, 0),
            (-1, -1, 0),
            (0, -1, 0),
            (1, -1, 0),
            (-1, 0, -1),
            (-1, -1, -1),
            (0, -1, -1),
            (1, -1, -1),
            (-1, 0, -2),
            (-1, -1, -2),
            (0, -1, -2),
            (1, -1, -2),
        ],
        "context_offsets_spectral": [(0, 0, -1), (0, 0, -2), (0, 0, -3),
                                     (0, 0, -4)],
    }

    models.FPCNN(hp=hyperparams, logname="test_init")
示例#4
0
        (-1, 0, -2),
        (-1, -1, -2),
        (0, -1, -2),
        (1, -1, -2),
    ],
    "context_offsets_spectral": [(0, 0, -1), (0, 0, -2), (0, 0, -3), (0, 0, -4)],
}
# endregion

# load data
LOG.info(f"Loading data from '{data_path}'")
data = datalib.load_data_hdf5(path=data_path, header=data_header)
data = data[0 : data_shape[0], 0 : data_shape[1], 0 : data_shape[2]]

# instantiate compressor model
model = models.FPCNN(hp=hyperparams, logname="compress_ip")

# get initial weights and biases to encode later
weights = model.get_weights()


data_compressed = model.compress(data=data)


LOG.info(
    f"Data compressed ({data_compressed.shape}, {data_compressed.dtype}):\n"
    f"{data_compressed}"
)

# mapping
data_mapped = encoding.map_residuals(data_compressed)