{"slug": "3d-spatial-transformer-network-2016", "title": "3D Spatial Transformer Network (2016)", "summary": "A 3D Spatial Transformer Network implementation for Torch, derived from the 2D version by @qassemoquab, is released with modules for affine 3D grid generation and trilinear sampling in BTHWC layout. The code includes an optional constrained transform matrix generator supporting scale and translation parameters, and the repository requests citation if used in research.", "body_md": "\n\n```\nluarocks make stn3d-scm-1.rockspec\n```\n\nThese are the basic modules (BTHWC layout) needed to implement a 3D variant of Spatial Transformer Network (Jaderberg et al.) [http://arxiv.org/abs/1506.02025](http://arxiv.org/abs/1506.02025)\n\n```\nrequire 'stn3d'\n\nnn.Affine3dGridGeneratorBTHWC(depth, height, width)\n-- takes B x 3 x 4 affine transform matrices as input,\n-- outputs a height x width grid in normalized [-1,1] coordinates\n-- output layout is B,T,H,W,3 where the first coordinate in the 5th dimension is z, and the second is y, third in x\n\nnn.TrilinearSamplerBTHWC()\n-- takes a table {inputVolumes, grids} as inputs\n-- outputs the interpolated volumes according to the grids\n-- inputImages is a batch of samples in BTHWC layout\n-- grids is a batch of grids (output of Affine3dGridGeneratorBTWC)\n-- output is also BTHWC\n```\n\nThis module allows the user to put a constraint on the possible transformations. It should be placed between the localisation network and the grid generator.\n\n```\nrequire 'stn3d'\n\nnn.Affine3dTransformMatrixGenerator(useScale, useTranslation)\n-- takes a B x nbParams tensor as inputs\n-- nbParams depends on the contrained transformation\n-- The parameters for the selected transformation(s) should be supplied in the\n-- following order: scaleFactor, translationZ, translationY, translationX\n-- If no transformation is specified, it generates a generic affine transformation (nbParams = 12)\n-- outputs B x 3 x 4 affine transform matrices\n```\n\nIf this code is useful to your research, please cite this repository.\n\nThis code is derived from the excellent [2D Spatial Transformer implementation](https://github.com/qassemoquab/stnbhwd) by [@qassemoquab](https://github.com/qassemoquab).", "url": "https://wpnews.pro/news/3d-spatial-transformer-network-2016", "canonical_source": "https://github.com/shubhtuls/stn3d", "published_at": "2026-09-02 02:34:59+00:00", "updated_at": "2026-09-02 02:52:04.336682+00:00", "lang": "en", "topics": ["machine-learning", "computer-vision", "neural-networks", "ai-research"], "entities": ["Torch", "Spatial Transformer Network", "Jaderberg et al.", "qassemoquab"], "alternates": {"html": "https://wpnews.pro/news/3d-spatial-transformer-network-2016", "markdown": "https://wpnews.pro/news/3d-spatial-transformer-network-2016.md", "text": "https://wpnews.pro/news/3d-spatial-transformer-network-2016.txt", "jsonld": "https://wpnews.pro/news/3d-spatial-transformer-network-2016.jsonld"}}