elektronn2.utils.cnncalculator module¶
-
elektronn2.utils.cnncalculator.
cnncalculator
(filters, poolings, desired_patch_size=None, mfp=False, force_center=False, desired_output=None, ndim=1)[source]¶ Helper to calculate CNN architectures
This is a function, but it returns an object that has various architecture values as attributes. Useful is also to simply print ‘d’ as in the example.
Parameters: - filters (list) – Filter shapes (for anisotropic filters the shapes are again a list)
- poolings (list) – Pooling factors
- desired_patch_size (int or list[int]) – Desired patch_size size(s). If
None
a range of suggestions can be found in the attributevalid_patch_sizes
- mfp (list[bool] or bool) – Whether to apply Max-Fragment-Pooling in this Layer and check compliance with max-fragment-pooling (requires other patch_size sizes than normal pooling)
- force_center (Bool) – Check if output neurons/pixel lie at center of patch_size neurons/pixel (and not in between)
- desired_output (None or int or list[int]) – Alternative to
desired_patch_size
- ndim (int) – Dimensionality of CNN
Examples
Calculation for anisotropic “flat” 3d CNN with mfp in the first layers only:
>>> desired_patch_size = [8, 211, 211] >>> filters = [[1,6,6], [4,4,4], [2,2,2], [1,1,1]] >>> pool = [[1,2,2], [2,2,2], [2,2,2], [1,1,1]] >>> mfp = [True, True, False, False ] >>> ndim=3 >>> d = cnncalculator(filters, pool, desired_patch_size, mfp=mfp, force_center=True, desired_output=None, ndim=ndim) patch_size (8) changed to (10) (size too small) patch_size (211) changed to (210) (size not possible) patch_size (211) changed to (210) (size not possible) >>> print(d) patch_size: [10, 210, 210] Layer/Fragment sizes: [(1, 24, 24), (1, 24, 24), (3, 49, 49), (10, 102, 102)] Unpooled Layer sizes: [(1, 24, 24), (2, 48, 48), (7, 99, 99), (10, 205, 205)] Receptive fields: [(9, 23, 23), (9, 23, 23), (5, 15, 15), (1, 7, 7)] Strides: [(4, 8, 8), (4, 8, 8), (2, 4, 4), (1, 2, 2)] Overlap: [(5, 15, 15), (5, 15, 15), (3, 11, 11), (0, 5, 5)] Offset: [4.5, 11.5, 11.5] If offset is non-int: output neurons lie centered on patch_size neurons,they have an odd FOV