In [ ]:
user_name = input("Please input Your name: ")
user_number = input("Please input your favorite number")

print("%s favorite number is %d" % (user_name, int(user_number)))

In [ ]:
grade = 5

In [ ]:
if grade != 5 : print("a"); print("b");

In [ ]:
import sys

In [ ]:
sys.stdin.encoding

In [ ]:
4/3

In [ ]:
4//3

In [ ]:
4%3

In [ ]:
3/4

In [ ]:
3//4

In [ ]:
3%4

In [ ]:
x_train = [1,2,3,4]
y_train = [2,4,6,8]

In [1]:
import numpy as np

In [2]:
x_train = np.array([[1,5],[2,6]])

In [3]:
x_train.shape


Out[3]:
(2, 2)

In [4]:
from keras.datasets import mnist


Using TensorFlow backend.

In [5]:
(x_train, y_train), (x_test, y_test) = mnist.load_data()

In [6]:
print(x_train.shape)


(60000, 28, 28)

In [7]:
type(x_train)


Out[7]:
numpy.ndarray

In [8]:
print(x_train[0])


[[  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   3  18  18  18 126 136
  175  26 166 255 247 127   0   0   0   0]
 [  0   0   0   0   0   0   0   0  30  36  94 154 170 253 253 253 253 253
  225 172 253 242 195  64   0   0   0   0]
 [  0   0   0   0   0   0   0  49 238 253 253 253 253 253 253 253 253 251
   93  82  82  56  39   0   0   0   0   0]
 [  0   0   0   0   0   0   0  18 219 253 253 253 253 253 198 182 247 241
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0  80 156 107 253 253 205  11   0  43 154
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0  14   1 154 253  90   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0 139 253 190   2   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0  11 190 253  70   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0  35 241 225 160 108   1
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0  81 240 253 253 119
   25   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0  45 186 253 253
  150  27   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  16  93 252
  253 187   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 249
  253 249  64   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0  46 130 183 253
  253 207   2   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0  39 148 229 253 253 253
  250 182   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0  24 114 221 253 253 253 253 201
   78   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0  23  66 213 253 253 253 253 198  81   2
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0  18 171 219 253 253 253 253 195  80   9   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0  55 172 226 253 253 253 253 244 133  11   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0 136 253 253 253 212 135 132  16   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]
 [  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    0   0   0   0   0   0   0   0   0   0]]

In [11]:
import matplotlib.pyplot as plt
%matplotlib inline

In [12]:
plt.imshow(x_train[0])


Out[12]:
<matplotlib.image.AxesImage at 0x1225425c0>

In [14]:
print(y_train[0])


5

In [15]:
a = [[1,2,3,4,5]]

In [16]:
plt.imshow(a)


Out[16]:
<matplotlib.image.AxesImage at 0x1225db208>

In [17]:
random_image = np.random.random([500,500])
plt.imshow(random_image, cmap='gray', interpolation='nearest')


Out[17]:
<matplotlib.image.AxesImage at 0x1230069b0>

In [18]:
from skimage import data

coins = data.coins()

print(type(coins), coins.dtype, coins.shape)
plt.imshow(coins, cmap='gray', interpolation='nearest')


<class 'numpy.ndarray'> uint8 (303, 384)
Out[18]:
<matplotlib.image.AxesImage at 0x128d67fd0>

In [19]:
from keras.preprocessing import  image

In [21]:
img = image.load_img('/Users/jaegyuhan/Pictures/study1.jpg')

In [22]:
plt.imshow(img)


Out[22]:
<matplotlib.image.AxesImage at 0x129a5f2e8>

In [23]:
from keras.preprocessing.sequence import pad_sequences

In [24]:
x_train = [[1,2,3],[4,5],[6]]

In [25]:
print(pad_sequences(x_train, 10))


[[0 0 0 0 0 0 0 1 2 3]
 [0 0 0 0 0 0 0 0 4 5]
 [0 0 0 0 0 0 0 0 0 6]]

In [26]:
print(pad_sequences(x_train, 2))


[[2 3]
 [4 5]
 [0 6]]

In [27]:
print(pad_sequences(x_train,5,padding='post'))


[[1 2 3 0 0]
 [4 5 0 0 0]
 [6 0 0 0 0]]

In [39]:
from keras.preprocessing.text import text_to_word_sequence
from keras.preprocessing.text import one_hot

In [40]:
x_train = "나는 머신러닝이 매우 좋아요...."

In [41]:
print(text_to_word_sequence(x_train))


['나는', '머신러닝이', '매우', '좋아요']

In [42]:
print(one_hot(x_train, len(text_to_word_sequence(x_train))))


[1, 2, 2, 1]

In [49]:
from sqlalchemy import create_engine
import pandas as pd

In [48]:
engine = create_engine('mysql+pymysql://ID:PASSWD@joojungchoi.cafe24.com:3306/jpa_ex')
sql = 'select * from tbl_members'

In [50]:
x_train = pd.read_sql(sql, engine)


/Users/jaegyuhan/anaconda3/lib/python3.5/site-packages/pymysql/cursors.py:170: Warning: (1287, "'@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead")
  result = self._query(query)

In [51]:
x_train.head()


Out[51]:
uid uname upw
0 user1 사용자1 pw1
1 user10 사용자10 pw10
2 user100 사용자100 pw100
3 user11 사용자11 pw11
4 user12 사용자12 pw12

In [ ]: