I have a Pytorch program that produces a customized version of CIFAR-10 on the fly (it does not save that customized CIFAR-10,but the program downloads the original dataset, customizes it, and uses it for training). I want to save that customized CIFAR-10 to disk and then use it to train a model written in TensorFlow, which is available online in Google Colab. My problem is: 1- How can I save that customized CIFAR-10 to disk from the Pytorch program? I use torch.save to save the returned object from the below line as a Pytorch tensor:
train_dataset = datasets.CIFAR10(root=data_dir, train=True, download=True, transform=train_transform)
torch.save(train_dataset, '../../../Customized_cifar_10.pt')
- I then convert the Pytorch tensor (i.e., Customized_cifar_10.pt) to a numpy array like this:
train_pytorch_tensor = tf.io.read_file("/content/Customized_cifar_10.pt")
(x_train, y_train) = train_pytorch_tensor.numpy()
Here I want x_train shape to be (50000, 32, 32, 3) and y_train shape to be (50000, 1)
ValueError Traceback (most recent call last)
<ipython-input-9-e6dca0bdb678> in <cell line: 23>()
21 # convert from pytorch tensors to numpy arrays.
22 train_pytorch_tensor = tf.io.read_file("/content/Customized_cifar_10.pt")
---> 23 (x_train, y_train) = train_pytorch_tensor.numpy()
ValueError: too many values to unpack (expected 2)
My method described above just does not work. Could any one tell me how to achieve that? I appreciate you help. Thank you!