# Np.asarray behaviour in pytorch and tensorflow

**URL:** <https://discuss.pytorch.org/t/np-asarray-behaviour-in-pytorch-and-tensorflow/55665>\
**Category:** Uncategorized\
**Created:** [September 11, 2019, 6:37am UTC](https://discuss.pytorch.org/t/np-asarray-behaviour-in-pytorch-and-tensorflow/55665 "2019-09-11T06:37:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhibkhan](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/muhibkhan/32/18379_2.png) [@muhibkhan](https://discuss.pytorch.org/u/muhibkhan)\
**Post date:** [September 11, 2019, 6:37am UTC](https://discuss.pytorch.org/t/np-asarray-behaviour-in-pytorch-and-tensorflow/55665/1 "2019-09-11T06:37:00Z")

</div>

Hello. I want my as output same as tensorflow output, but i’m unable to figuring out how array behaves? Why np.array perform the same way as in tensorflow and what is the difference between the output of tensorflow and pytorch, desdpite that both are tensors with dim = 10? Is there any other thing which i’m doing wrong

 ![output](https://discuss.pytorch.org/uploads/default/original/2X/5/5c0699ad7ce28ddefe7f79a5b1b7f691f3cd6c99.png)

tensorflow output = [1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]  
pytorch output = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]

---

<div class="post-metadata">

**Author:** ![spanev](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/spanev/32/14892_2.png) [@spanev](https://discuss.pytorch.org/u/spanev)\
**Post date:** [September 11, 2019, 11:34am UTC](https://discuss.pytorch.org/t/np-asarray-behaviour-in-pytorch-and-tensorflow/55665/2 "2019-09-11T11:34:28Z")

</div>

Hi @muhibkhan,

There are both the same, of shape `(10)`. The difference you see is just an aesthetic difference in the printing.  
If you print `tensor1` or `tensor2` shape and type in PyTorch you will have:

```auto
torch.Size([10]), torch.float32

```

which is strictly equivalent to TensorFlow’s `TensorShape([Dimension(10)])` that you see.

---

<div class="post-metadata">

**Author:** ![muhibkhan](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/muhibkhan/32/18379_2.png) [@muhibkhan](https://discuss.pytorch.org/u/muhibkhan)\
**Post date:** [September 11, 2019, 11:54am UTC](https://discuss.pytorch.org/t/np-asarray-behaviour-in-pytorch-and-tensorflow/55665/3 "2019-09-11T11:54:08Z")

</div>

So logically both outputs like:  
tensorflow output = [1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]  
pytorch output = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]

are same. Comma separation ( **,** ) doesn’t have any affect.

---

<div class="post-metadata">

**Author:** ![spanev](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/spanev/32/14892_2.png) [@spanev](https://discuss.pytorch.org/u/spanev)\
**Post date:** [September 11, 2019, 11:54am UTC](https://discuss.pytorch.org/t/np-asarray-behaviour-in-pytorch-and-tensorflow/55665/4 "2019-09-11T11:54:46Z")

</div>

> [@muhibkhan](#):
>
> are same. Comma separation ( **,** ) doesn’t have any affect.

Correct, that’s what I meant. 🙂
