akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
How to apply Sampler to two dataset in single dataloader?

username: vishalthengane
cooked: <p>I am trying to apply WeightedRandomSample on single DataLoader which has two datasets with the same data size but different class distribution. I am using the following code to merge two datasets.</p>
<pre><code class="lang-auto">class TwoDatasets(Dataset):
	def __init__(self, dataset1_, dataset2_):
		self.dataset1 = dataset1_
		self.dataset2 = dataset2_

	def __getitem__(self, index):
		data1, target1 = self.dataset1[index]
		data2, target2 = self.dataset2[index]

		return (data1, target1), (data2, target2)

	def __len__(self):
		return min(len(self.dataset1), len(self.dataset2))
	

root = './path/to/dataset'	

transform = transforms.Compose([
				transforms.Resize([224, 224]), 
				transforms.ToTensor(), 
				transforms.Normalize([0.485, 0.456, 0.406], 
						 [0.229, 0.224, 0.225]), 
					])

dataset1 = datasets.ImageFolder(os.path.join(root, 'dataset1'), transform)
dataset2 = datasets.ImageFolder(os.path.join(root, 'dataset2'), transform)

two_dataset = TwoDatasets(dataset1, dataset2)
dataloader = DataLoader(two_dataset, batch_size=batch_size, sampler=?)
</code></pre>
<p>How I can apply Sampler to the DataLoader so that I will manage to balance both the datasets?</p>
<p>Thanks!</p>
How to manager multiple pytorch visions in same server?

username: phaypyt
cooked: <p>I want to install pytorch v1.2 from source on my server, which got v1.1 through <code>pip install pytorch_v1.1.whl</code> already.<br>
How should I manager that multiple version of pytorch? And how to switch between them?</p>

username: Deepali
cooked: <p>Conda environments - with an environment for each version of PyTorch.</p>

username: phaypyt
cooked: <p>My first vision of pytorch is install by <code>pip</code>, second version is installed from source, will that leads to any confusion if that installation is in different conda env?</p>

username: Deepali
cooked: <p>Environments make multiple versions coexist, so I don’t think so.</p>