Skip to content

Commit 48fd77e

Browse files
authored
week08:autoenconders_torch make tensors from X for assert checking
1 parent 4a483a5 commit 48fd77e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

week08_autoencoders/autoencoders_torch.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,9 @@
764764
"source": [
765765
"#noise tests\n",
766766
"theoretical_std = (X[:100].std()**2 + 0.5**2)**.5\n",
767-
"our_std = apply_gaussian_noise(X[:100],sigma=0.5).std()\n",
767+
"our_std = apply_gaussian_noise(torch.from_numpy(X[:100]),sigma=0.5).std()\n",
768768
"assert abs(theoretical_std - our_std) < 0.01, \"Standard deviation does not match it's required value. Make sure you use sigma as std.\"\n",
769-
"assert abs(apply_gaussian_noise(X[:100],sigma=0.5).mean() - X[:100].mean()) < 0.01, \"Mean has changed. Please add zero-mean noise\""
769+
"assert abs(apply_gaussian_noise(torch.from_numpy(X[:100]),sigma=0.5).mean() - torch.from_numpy(X[:100]).mean()) < 0.01, \"Mean has changed. Please add zero-mean noise\""
770770
]
771771
},
772772
{
@@ -801,11 +801,11 @@
801801
"plt.subplot(1,4,1)\n",
802802
"plt.imshow(X[0].transpose([1,2,0]))\n",
803803
"plt.subplot(1,4,2)\n",
804-
"plt.imshow(apply_gaussian_noise(X[:1],sigma=0.01).data.numpy()[0].transpose([1,2,0]).clip(0, 1))\n",
804+
"plt.imshow(apply_gaussian_noise(torch.from_numpy(X[:1]),sigma=0.01).data.numpy()[0].transpose([1,2,0]).clip(0, 1))\n",
805805
"plt.subplot(1,4,3)\n",
806-
"plt.imshow(apply_gaussian_noise(X[:1],sigma=0.1).data.numpy()[0].transpose([1,2,0]).clip(0, 1))\n",
806+
"plt.imshow(apply_gaussian_noise(torch.from_numpy(X[:1]),sigma=0.1).data.numpy()[0].transpose([1,2,0]).clip(0, 1))\n",
807807
"plt.subplot(1,4,4)\n",
808-
"plt.imshow(apply_gaussian_noise(X[:1],sigma=0.5).data.numpy()[0].transpose([1,2,0]).clip(0, 1))"
808+
"plt.imshow(apply_gaussian_noise(torch.from_numpy(X[:1]),sigma=0.5).data.numpy()[0].transpose([1,2,0]).clip(0, 1))"
809809
]
810810
},
811811
{

0 commit comments

Comments
 (0)