Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTORCH Question!!! We have the following PYTORCH TENSOR: How do I write a loop such that I can convert this Pytorch tensor to a pandas

PYTORCH Question!!!

We have the following PYTORCH TENSOR:

image text in transcribed

How do I write a loop such that I can convert this Pytorch tensor to a pandas dataframe that looks like the following:

183 rows, in which each row has a total of 33*20 = 660 columns!! In other words, I simply want to take all the elements from each 33 x 20 tensor (there are 183 of these in total) and make them a row in my pandas df so that there are 660 feature (columns), each storing one value from the original tensor. Thanks in advance!!

0.070... 0.066212378 Tensor: b_fp Tensor with shape torch.Size([183, 33, 20]) b_fp 0.0000e+00, 0.00002+00, - tensor( [[[6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.00002+00], [6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.0000e+00], [6.9605e+00, 2.3818e+00, 7.0687e-02, 0.00002+00, 0.0000e+00], 0.0000e+00, 0.0000e+00, 0.00002+00, [6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.00002+00], [6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.0000e+00], [6.0452e+00, 2.3243e+00, 5.6076e-01, 0.0000e+00, 0.0000e+00]], 0.00002+00, 0.0000e+00, 0.00002+00, [[6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.00002+00], [6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.00002+00], [6.9605e+00, 2.3818e+00, 7.0687e-02, 0.0000e+00, 0.0000e+00], 0.0000e+00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Differentiate tan(7x+9x-2.5)

Answered: 1 week ago

Question

Explain the sources of recruitment.

Answered: 1 week ago

Question

Differentiate sin(5x+2)

Answered: 1 week ago

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago

Question

2. Employees and managers participate in development of the system.

Answered: 1 week ago