Question: I was recently working with Python and wanted to use another way of finding square roots. For example I wanted to find square root of n with Newton-Raphson approximation. I need to overload the overload the `**` (only when you raise a number to 0.5),o perator as well as `math.sqrt()`, because I have several older projects that could be sped up by doing so and replacing all `math.sqrt()` and `**(0.5)` with another function isn't ideal.

Could this be done in Python?

Is it possible to overload either `**` or `math.sqrt`?

Any helpful links are also much appreciated.

```
def Square_root(n):
    r = n/2
    while(abs(r-(n/r)) > t):
        r = 0.5 * (r + (n/r))
    return r

print(2**(0.5)) ## changes to print(Square_root(2))
print(math.sqrt(2)) ## that also becomes print(Square_root(2))

```

Answer: 
I think the error comes because in the `transform.Compose` you are doing first `.ToTensor()` and, instead, you should do `.Scale()`. `Pytorch` has transformations on **tensors** and on **PIL Images**, that are *not* interchangeable.
Reading the docs it says 

> 
> class torchvision.transforms.Scale(size, interpolation=2) [...]
>  Rescale the input PIL.Image to the given size.
> 
> 
> 

While you are changing that image to a Pytorch tensor before scaling thus making it crash.

It should be changed to:

```
transform = transforms.Compose(
                   [transforms.Scale((32,32)),
                    transforms.ToTensor(),
                    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

```

You will get this error when applying `PIL Image` transformations on tensors.
This might be as simple as you not providing the correct path to the "imgs" folder. Are you running your program from the same folder as the "imgs" folder? Try specifying an absolute path to your "imgs" folder and see if it helps.