# RuntimeError: exp\_vml\_cpu not implemented for 'Long'

**URL:** <https://discuss.pytorch.org/t/runtimeerror-exp-vml-cpu-not-implemented-for-long/49025>\
**Category:** Uncategorized\
**Created:** [June 26, 2019, 2:38pm UTC](https://discuss.pytorch.org/t/runtimeerror-exp-vml-cpu-not-implemented-for-long/49025 "2019-06-26T14:38:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Halil\_Yildirim](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/halil_yildirim/32/13502_2.png) [@Halil\_Yildirim](https://discuss.pytorch.org/u/Halil_Yildirim)\
**Post date:** [June 26, 2019, 2:38pm UTC](https://discuss.pytorch.org/t/runtimeerror-exp-vml-cpu-not-implemented-for-long/49025/1 "2019-06-26T14:38:01Z")

</div>

I want to define an activation function for my model. The activation function I want to use is the sigmoid function.

I define this activation function.

```auto
import torch
def sigmoid(z):
   return 1/(1+torch.exp(-z))
X = np.array([0])
t = torch.from_numpy(X)
sigmoid(t)

```

RuntimeError: exp\_vml\_cpu not implemented for ‘Long’

> But when use X = np.array([0.]) I don’t get any error. Why that occurs?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [June 26, 2019, 2:42pm UTC](https://discuss.pytorch.org/t/runtimeerror-exp-vml-cpu-not-implemented-for-long/49025/2 "2019-06-26T14:42:31Z")

</div>

`torch.from_numpy` keeps the `dtype`.  
If you initialize the numpy array with `0`, it will result in `t` being a `LongTensor`, while `0.` yields a `FloatTensor`.  
The method `torch.exp` is not implemented for `LongTensors`, which throws this error.
