Skip to main content

Roll 2d tensor to 3d and vice versa.

Project description

torch-roller

  • Roll 2d tensor to 3d and vice versa.
>>> df = pd.DataFrame()
>>> df["A"] = [1, 2, 3, 4, 5]
>>> df["B"] = [10, 20, 30, 40, 50]
>>> df.values
array([[ 1, 10],
       [ 2, 20],
       [ 3, 30],
       [ 4, 40],
       [ 5, 50]], dtype=int64)
>>> tensor_3d = roll(df, length=3)
>>> tensor_3d
tensor([[[ 1., 10.],       
         [ 2., 20.],       
         [ 3., 30.]],      

        [[ 2., 20.],       
         [ 3., 30.],       
         [ 4., 40.]],      

        [[ 3., 30.],       
         [ 4., 40.],       
         [ 5., 50.]]])     
>>> df_2d = unroll(tensor_3d)
>>> df_2d.values
array([[ 1., 10.],
       [ 2., 20.],
       [ 3., 30.],
       [ 4., 40.],
       [ 5., 50.]], dtype=float32)
>>> assert np.array_equal(df.values, df_2d.values)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch_roller-0.1.0.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torch_roller-0.1.0-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

Details for the file torch_roller-0.1.0.tar.gz.

File metadata

  • Download URL: torch_roller-0.1.0.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.4 CPython/3.12.3 Windows/11

File hashes

Hashes for torch_roller-0.1.0.tar.gz
Algorithm Hash digest
SHA256 43ea26b85fa5e2217bded0642ee10c3cd5b8164163346619d475b662ccc4e8cc
MD5 71a715c1cd95ab687a3355e09ed482d8
BLAKE2b-256 329fc378b2a5b67e8dd6316246bed1cf227dc89203ebac2e0aea8c7dff417866

See more details on using hashes here.

File details

Details for the file torch_roller-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: torch_roller-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.4 CPython/3.12.3 Windows/11

File hashes

Hashes for torch_roller-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 171cb68add47c27f43c9a916b3067c0424a43fd2f0500dc5fad1cdcf11d8b10c
MD5 a7d953f66ecea876633d8a5179adf7cb
BLAKE2b-256 836aa8b33922185349237ae0ddd4fb59bc29545137cbbf726a9b7a4312a6b1c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page