Python> Difference between inpbt and print (inpbt) output> [1. 2. 3.] / array ([1., 2., 3.], dtype = float32)

Operating environment


GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)

Questions I had while implementing the TensorFlow code.

>>> import numpy as np
>>> inpbt = np.array([1,2,3], dtype='f')
>>> print(inpbt)
[ 1.  2.  3.]
>>> inpbt
array([ 1.,  2.,  3.], dtype=float32)

It is implemented by the code learn_xxyyfunc_170321.py, and when the input batch is output by print (), it becomes the latter notation of ʻarray (..., dtype = ...)`.

On the other hand, when executing in interactive mode (?) As described above, in the example using print (), the notation of ʻarray and dtype` is not seen.

I also tried a short script.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np

# on Python 2.7.6

inpbt = np.array([1,2,3], dtype='f')
print(inpbt)

Run


$ python test_python_170324a.py 
[ 1.  2.  3.]

Is there any option to use ʻarray (..., dtype = ...)` notation when executing a Python script?

test_python_170324a.py


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np

# Python 2.7.6

inpbt = np.array([1,2,3], dtype='f')
print(inpbt)
alist = list([inpbt])
print(alist)

Run


$ python test_python_170324a.py 
[ 1.  2.  3.]
[array([ 1.,  2.,  3.], dtype=float32)]

If you enclose the list type with [] and enclose it with list (), it becomes ʻarray (..., dtype = ...)` notation.

Recommended Posts

Python> Difference between inpbt and print (inpbt) output> [1. 2. 3.] / array ([1., 2., 3.], dtype = float32)
[python] Difference between rand and randn output
Difference between java and python (memo)
Difference between list () and [] in Python
Difference between == and is in python
Difference between python2 series and python3 series dict.keys ()
[Python] Difference between function and method
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
difference between statements (statements) and expressions (expressions) in Python
Difference between PHP and Python finally and exit
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
[Python] Difference between class method and static method
[Python Iroha] Difference between List and Tuple
[python] Difference between variables and self. Variables in class
About the difference between "==" and "is" in python
python input and output
Difference between Ruby and Python in terms of variables
Difference between return, return None, and no return description in Python
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
Python module num2words Difference in behavior between English and Russian
Difference between regression and classification
List concatenation method in python, difference between list.extend () and “+” operator
Difference between np.array and np.arange
Difference between MicroPython and CPython
Difference between ps a and ps -a
Difference between return and print-Python
Difference in how to write if statement between ruby ​​and python
Transcendental simple and clear! !! Difference between single quotes and double quotes in Python
Python / Numpy> Link> Difference between numpy.random and random.random> thread-safe or not
File open function in Python3 (difference between open and codecs.open and speed comparison)
Difference between SQLAlchemy filter () and filter_by ()
Memorandum (difference between csv.reader and csv.dictreader)
(Note) Difference between gateway and default gateway
Cooperation between python module and API
[Code] Module and Python version output
Difference between Numpy randint and Random randint
Differences between Python, stftime and strptime
Difference between sort and sorted (memorial)
Export and output files in Python
Compare Python and JavaScript array loops
Difference between SQLAlchemy flush () and commit ()
Python> Extract (unpack) the value of list> Add *> You taught me the difference between Python 2 and Python 3 regarding print (* mylist) / print ().
Communicate between Elixir and Python with gRPC
Differences between Ruby and Python in scope
[Xg boost] Difference between softmax and softprob
[Django ORM] Difference between values () and only ()
Differences in syntax between Python and Java
Python> link> 2D array initialization and assignment
Difference between linear regression, Ridge regression and Lasso regression
Difference between docker-compose env_file and .env file
[Python3] Switch between Shift_JIS, UTF-8 and ASCII
speed difference between wsgi, Bottle and Flask
Differences between Numpy 1D array [x] and 2D array [x, 1]
Differences in multithreading between Python and Jython
Differences between Ruby and Python (basic syntax)
Difference between numpy.ndarray and list (dimension, size)
Correspondence between Python built-in functions and Rust