python> Copy and paste code> SyntaxError: Non-ASCII character'\ xe3' in file>-*-coding: utf-8-*-Add

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

A program using a deep learning framework called TensorFlow is being tried.

I tried the sample code to read the csv file. http://qiita.com/learn_tensorflow/items/3e46b2512a1bab73f5b2

We did the following:

  1. Create a new 3e46b2512a1bab73f5b2.py --Open with Sublime Text
  2. Copy the Qiita article code (train.py) in Chrome
  3. Paste with Sublime Text
  4. python 3e46b2512a1bab73f5b2.py

I got the following error:

$ python 3e46b2512a1bab73f5b2.py 
  File "3e46b2512a1bab73f5b2.py", line 4
SyntaxError: Non-ASCII character '\xe3' in file 3e46b2512a1bab73f5b2.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

The following areas may be relevant. http://yono.cc/python/python_basics/japanese.html

Coping

Based on the link above, we did the following:

The following two lines have been added to the beginning of 3e46b2512a1bab73f5b2.py.

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

The error no longer appears in python 3e46b2512a1bab73f5b2.py.

I also confirmed that it works even if only the second line (line of utf-8) is added to the beginning.

However, this time it seems that another error will occur.

I forgot to create input.csv. When I created it, it worked normally.

$ python 3e46b2512a1bab73f5b2.py 
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
WARNING:tensorflow:sum_of_squares (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-10-01.
Instructions for updating:
Use mean_squared_error.
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:951] Found device 0 with properties: 
name: GeForce GTX 1070
major: 6 minor: 1 memoryClockRate (GHz) 1.7715
pciBusID 0000:01:00.0
Total memory: 7.91GiB
Free memory: 7.43GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:972] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)
step 100: loss=0.247862
step 200: loss=0.247688
step 300: loss=0.247384
step 400: loss=0.241975
step 500: loss=0.238029
step 600: loss=0.162714
step 700: loss=0.073538
step 800: loss=0.032851
step 900: loss=0.016584
step 1000: loss=0.008190
step 1100: loss=0.007613
step 1200: loss=0.005846
step 1300: loss=0.004516
step 1400: loss=0.003045
step 1500: loss=0.003138
step 1600: loss=0.002398
step 1700: loss=0.002074
step 1800: loss=0.001769
step 1900: loss=0.001600
step 2000: loss=0.001209

Recommended Posts

python> Copy and paste code> SyntaxError: Non-ASCII character'\ xe3' in file>-*-coding: utf-8-*-Add
Character code learned in Python
Today's python error: SyntaxError Non-ASCII character
Links and memos of Python character code strings
python2 series / 3 series, character code and print statement / command line
About Python3 character code
Spit out a list of file name, last modified date and character code in python3
Manipulate the clipboard in Python and paste the table into Excel
Create code that outputs "A and pretending B" in python
Specification generation and code generation in REST API development (Python edition)
3-3, Python strings and character codes
Python shallow copy and deep copy
Python shallow and deep copy
2.x, 3.x character code of python
Stack and Queue in Python
Generate QR code in Python
Unittest and CI in Python
Python # About reference and copy