GithubHelp home page GithubHelp logo

jskdr / keraspp Goto Github PK

View Code? Open in Web Editor NEW
177.0 20.0 96.0 6.87 MB

코딩셰프의 3분 딥러닝, 케라스맛

License: MIT License

Python 3.24% Jupyter Notebook 96.76%
ann dnn cnn rnn ae gan unet keras tensorflow

keraspp's People

Contributors

jskdr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keraspp's Issues

ex7_2_gan_cnn_mnist_tf.py를 실행하니 다음과 같은 에러가 납니다.

Using TensorFlow backend.
<function image_data_format at 0x7fb6200a4d90>
Output_fold is GAN_OUT
2018-11-25 08:56:45.589349: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to
use: SSE4.1 SSE4.2 AVX
2018-11-25 08:56:45.679946: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there
must be at least one NUMA node, so returning NUMA node zero
2018-11-25 08:56:45.680395: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties:
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:00:04.0
totalMemory: 11.17GiB freeMemory: 11.09GiB
2018-11-25 08:56:45.680431: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0
2018-11-25 08:56:46.007533: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-11-25 08:56:46.007606: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0
2018-11-25 08:56:46.007617: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N
2018-11-25 08:56:46.007899: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 wi
th 10749 MB memory) -> physical GPU (device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7)
Epoch is 0
Number of batches 2
Traceback (most recent call last):
File "ex7_2_gan_cnn_mnist_tf.py", line 211, in
main()
File "ex7_2_gan_cnn_mnist_tf.py", line 207, in main
train(args)
File "ex7_2_gan_cnn_mnist_tf.py", line 166, in train
d_loss, g_loss = gan.train_both(x)
File "ex7_2_gan_cnn_mnist_tf.py", line 97, in train_both
g_loss = self.train_on_batch(z, [1] * ln)
File "/home/zeroone_gcp/anaconda3/envs/env-py36-gym-tf/lib/python3.6/site-packages/keras/engine/training.py", line 1211, in train_on_batch
class_weight=class_weight)
File "/home/zeroone_gcp/anaconda3/envs/env-py36-gym-tf/lib/python3.6/site-packages/keras/engine/training.py", line 677, in _standardize_user_data
self._set_inputs(x)
File "/home/zeroone_gcp/anaconda3/envs/env-py36-gym-tf/lib/python3.6/site-packages/keras/engine/training.py", line 636, in _set_inputs
outputs = self.call(unpack_singleton(self.inputs))
File "/home/zeroone_gcp/anaconda3/envs/env-py36-gym-tf/lib/python3.6/site-packages/keras/engine/network.py", line 561, in call
if cache_key in self._output_tensor_cache:
AttributeError: 'GAN' object has no attribute '_output_tensor_cache'

환경은 다음과 같습니다. (conda list)

packages in environment at

Name Version Build Channel

_tflow_select 2.1.0 gpu
absl-py 0.6.1 py36_0
astor 0.7.1 py36_0
atari-py 0.1.6
backcall 0.1.0 py36_0
blas 1.0 mkl
bleach 3.0.2 py36_0
box2d-py 2.3.5
c-ares 1.15.0 h7b6447c_1
ca-certificates 2018.03.07 0
certifi 2018.10.15 py36_0
chardet 3.0.4
cloudpickle 0.6.1 py36_0
cudatoolkit 9.2 0
cudnn 7.2.1 cuda9.2_0
cupti 9.2.148 0
cycler 0.10.0 py36_0
dask-core 0.20.2 py36_0
dbus 1.13.2 h714fa37_1
decorator 4.3.0 py36_0
entrypoints 0.2.3 py36_2
expat 2.2.6 he6710b0_0
fontconfig 2.13.0 h9420a91_0
freetype 2.9.1 h8a8886c_1
future 0.17.1
gast 0.2.0 py36_0
glib 2.56.2 hd408876_0
gmp 6.1.2 h6c8ec71_1
grpcio 1.14.1 py36h9ba97e2_0
gst-plugins-base 1.14.0 hbbd80ab_1
gstreamer 1.14.0 hb453b48_1
gym 0.10.9
h5py 2.8.0 py36h989c5e5_3
hdf5 1.10.2 hba1933b_1
icu 58.2 h9c2bf20_1
idna 2.7
imageio 2.4.1 py36_0
intel-openmp 2019.0 118
ipykernel 5.1.0 py36h39e3cac_0
ipython 7.1.1 py36h39e3cac_0
ipython_genutils 0.2.0 py36_0
ipywidgets 7.4.2 py36_0
jedi 0.13.1 py36_0
jinja2 2.10 py36_0
jpeg 9b h024ee3a_2
jsonschema 2.6.0 py36_0
jupyter 1.0.0 py36_7
jupyter_client 5.2.3 py36_0
jupyter_console 6.0.0 py36_0
jupyter_core 4.4.0 py36_0
keras 2.2.4 0
keras-applications 1.0.6 py36_0
keras-base 2.2.4 py36_0
keras-preprocessing 1.0.5 py36_0
kiwisolver 1.0.1 py36hf484d3e_0
libedit 3.1.20170329 h6b74fdf_2
libffi 3.2.1 hd88cf55_4
libgcc-ng 8.2.0 hdf63c60_1
libgfortran-ng 7.3.0 hdf63c60_0
libpng 1.6.35 hbc83047_0
libprotobuf 3.6.1 hd408876_0
libsodium 1.0.16 h1bed415_0
libstdcxx-ng 8.2.0 hdf63c60_1
libtiff 4.0.9 he85c1e1_2
libuuid 1.0.3 h1bed415_2
libxcb 1.13 h1bed415_1
libxml2 2.9.8 h26e45fe_1
markdown 3.0.1 py36_0
markupsafe 1.0 py36h14c3975_1
matplotlib 3.0.1 py36h5429711_0
mistune 0.8.4 py36h7b6447c_0
mkl 2018.0.3 1
mkl_fft 1.0.6 py36h7dd41cf_0
mkl_random 1.0.1 py36h4414c95_1
nbconvert 5.3.1 py36_0
nbformat 4.4.0 py36_0
ncurses 6.1 hf484d3e_0
networkx 2.2 py36_1
notebook 5.7.0 py36_0
numpy 1.15.4 py36h1d66e8a_0
numpy 1.15.4
numpy-base 1.15.4 py36h81de0dd_0
olefile 0.46 py36_0
openssl 1.0.2p h14c3975_0
pandas 0.23.4 py36h04863e7_0
pandoc 2.2.3.2 0
pandocfilters 1.4.2 py36_1
parso 0.3.1 py36_0
patsy 0.5.1 py36_0
pcre 8.42 h439df22_0
pexpect 4.6.0 py36_0
pickleshare 0.7.5 py36_0
Pillow 5.3.0
pillow 5.3.0 py36h34e0f95_0
pip 18.1 py36_0
prometheus_client 0.4.2 py36_0
prompt_toolkit 2.0.7 py36_0
protobuf 3.6.1 py36he6710b0_0
ptyprocess 0.6.0 py36_0
pudb 2018.1
pydot 1.2.4 py36_0
pyglet 1.3.2
pygments 2.2.0 py36_0
PyOpenGL 3.1.0
pyparsing 2.3.0 py36_0
pyqt 5.9.2 py36h05f1152_2
python 3.6.6 h6e4f718_2
python-dateutil 2.7.5 py36_0
pytz 2018.7 py36_0
pywavelets 1.0.1 py36hdd07704_0
pyyaml 3.13 py36h14c3975_0
pyzmq 17.1.2 py36h14c3975_0
qt 5.9.6 h8703b6f_2
qtconsole 4.4.2 py36_0
readline 7.0 h7b6447c_5
requests 2.20.0
scikit-image 0.14.0 py36hf484d3e_1
scikit-learn 0.20.0
scipy 1.1.0
scipy 1.1.0 py36hfa4b5c9_1
seaborn 0.9.0 py36_0
send2trash 1.5.0 py36_0
setuptools 40.5.0 py36_0
sip 4.19.8 py36hf484d3e_0
six 1.11.0
six 1.11.0 py36_1
sklearn 0.0
sqlite 3.25.2 h7b6447c_0
statsmodels 0.9.0 py36h035aef0_0
tensorboard 1.11.0 py36hf484d3e_0
tensorflow 1.11.0 gpu_py36h9c9050a_0
tensorflow-base 1.11.0 gpu_py36had579c0_0
tensorflow-gpu 1.11.0 h0d30ee6_0
termcolor 1.1.0 py36_1
terminado 0.8.1 py36_1
testpath 0.4.2 py36_0
tk 8.6.8 hbc83047_0
toolz 0.9.0 py36_0
tornado 5.1.1 py36h7b6447c_0
traitlets 4.3.2 py36_0
urllib3 1.24.1
urwid 2.0.1
wcwidth 0.1.7 py36_0
webencodings 0.5.1 py36_1
werkzeug 0.14.1 py36_0
wheel 0.32.2 py36_0
widgetsnbextension 3.4.2 py36_0
xz 5.2.4 h14c3975_4
yaml 0.1.7 had09818_2
zeromq 4.2.5 hf484d3e_1
zlib 1.2.11 ha838bed_2

Conv2D 사이즈 관련 질문드립니다

z = Conv2D(1, (7, 7))(x)

리포지토리 코드와 책에 따르면 인코딩 모델의 마지막 레이어는 7x7 사이즈를 갖도록 설정되었는데요,

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_12 (InputLayer)        (None, 28, 28, 1)         0         
_________________________________________________________________
cnn1 (Conv2D)                (None, 26, 26, 4)         40        
_________________________________________________________________
max_pooling1 (MaxPooling2D)  (None, 13, 13, 4)         0         
_________________________________________________________________
cnn3 (Conv2D)                (None, 11, 11, 8)         296       
_________________________________________________________________
max_pooling2 (MaxPooling2D)  (None, 6, 6, 8)           0         # <--- 이 부분
_________________________________________________________________
final_cnn (Conv2D)           (None, 1, 1, 1)           289       
=================================================================
Total params: 625
Trainable params: 625
Non-trainable params: 0
_________________________________________________________________

max_pooling2 레이어의 출력값이 6x6 인데 CNN 7x7 을 사용할 수 있나요?

위 summary() 결과를 얻기 위해 사용한 모델 코드는 아래와 같습니다.

        input_layer = Input(shape=self.input_shape)
        
        x = Conv2D(4, (3, 3), name='cnn1')(input_layer)
        x = MaxPooling2D((2, 2), padding='same', name='max_pooling1')(x)
        x = Conv2D(8, (3, 3), name='cnn3')(x)
        x = MaxPooling2D((2, 2), padding='same', name='max_pooling2')(x)
        
        output_layer = Conv2D(1, (6, 6), name='final_cnn')(x)

또한 7x7 사이즈의 CNN 을 사용했을 때, 나오는 에러는 아래와 같습니다.

ValueError: Negative dimension size caused by subtracting 7 from 6 for 'final_cnn_4/convolution' (op: 'Conv2D') with input shapes: [?,6,6,8], [7,7,8,1].

ANN/DNN에서 weight와 bias값들을 출력 할 수 있나요?

제가 keras에서 구현한 ANN 혹은 DNN 학습 결과를 C/C++로 된 프로그램에 적용하고자 합니다.
그러기 위해서 C/C++로 Neural network 코드를 만들었고, keras에서 계산한 hidden layer와 출력 layer의
weight와 bias 값을 출력해서 C/C++ 코드에 적용하려고 합니다.
가능할까요? 부탁 드립니다!

ex6_1_ae를 cpu 텐서플로에서 돌리면 epochs를 늘여도 수렴이 잘 안됩니다.

파이썬3.7, 텐서플로2.0 cpu 버전입니다.
에포크에 따른 accuracy 변화는 아래와 같습니다.
책에 나온 결과와 차이가 매우 크게 납니다.

왜 그런 걸까요.


runfile('D:/Python/merong.py', wdir='D:/Python')
(60000, 784)
(10000, 784)
Train on 60000 samples, validate on 10000 samples
Epoch 1/10
60000/60000 [==============================] - 7s 123us/sample - loss: 0.6959 - accuracy: 0.3923 - val_loss: 0.6958 - val_accuracy: 0.3924
Epoch 2/10
60000/60000 [==============================] - 5s 84us/sample - loss: 0.6956 - accuracy: 0.3941 - val_loss: 0.6956 - val_accuracy: 0.3943
Epoch 3/10
60000/60000 [==============================] - 6s 108us/sample - loss: 0.6954 - accuracy: 0.3959 - val_loss: 0.6954 - val_accuracy: 0.3960
Epoch 4/10
60000/60000 [==============================] - 6s 104us/sample - loss: 0.6952 - accuracy: 0.3978 - val_loss: 0.6952 - val_accuracy: 0.3979
Epoch 5/10
60000/60000 [==============================] - 5s 86us/sample - loss: 0.6950 - accuracy: 0.3995 - val_loss: 0.6950 - val_accuracy: 0.3996
Epoch 6/10
60000/60000 [==============================] - 6s 101us/sample - loss: 0.6948 - accuracy: 0.4013 - val_loss: 0.6948 - val_accuracy: 0.4014
Epoch 7/10
60000/60000 [==============================] - 5s 87us/sample - loss: 0.6946 - accuracy: 0.4031 - val_loss: 0.6946 - val_accuracy: 0.4032
Epoch 8/10
60000/60000 [==============================] - 5s 84us/sample - loss: 0.6944 - accuracy: 0.4048 - val_loss: 0.6944 - val_accuracy: 0.4049
Epoch 9/10
60000/60000 [==============================] - 8s 134us/sample - loss: 0.6942 - accuracy: 0.4066 - val_loss: 0.6942 - val_accuracy: 0.4067
Epoch 10/10
60000/60000 [==============================] - 5s 90us/sample - loss: 0.6940 - accuracy: 0.4083 - val_loss: 0.6940 - val_accuracy: 0.4084

ex9_3_advanced_keras.py 에서 발생하는 ValueError

Backend_for_Lambda()yp = m.predict_on_batch([[1, 2, 3], [3, 4, 8]]) 부분에서 다음과 같은 에러가 발생하고 있습니다.

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays: [array([[1],
       [2],
       [3]]), array([[3],
       [4],
       [8]])]...

https://keras.io/ko/models/sequential/의 predict_on_batch를 참고해 보았지만, 어떻게 해결하면 좋을지 문의하고자 이슈 남깁니다.

ex4_2_cnn_cifar10_cl 실행하니 you forgot to call super(YourClass, self).__init__() 에러가 납니다.

ex4_2_cnn_cifar10_cl 실행하니 아래와 같은 에러가 납니다.
도와주세요.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/softg/PycharmProjects/test/keraspp/ex4_2_cnn_cifar10_cl.py", line 22, in <module>
    main()
  File "C:/Users/softg/PycharmProjects/test/keraspp/ex4_2_cnn_cifar10_cl.py", line 18, in main
    m = Machine()
  File "C:/Users/softg/PycharmProjects/test/keraspp/ex4_2_cnn_cifar10_cl.py", line 14, in __init__
    super().__init__(X, y, nb_classes=10)
  File "C:\Users\softg\PycharmProjects\test\keraspp\keraspp\aicnn.py", line 125, in __init__
    self.set_model()
  File "C:\Users\softg\PycharmProjects\test\keraspp\keraspp\aicnn.py", line 136, in set_model
    self.model = CNN(nb_classes=nb_classes, in_shape=data.input_shape)
  File "C:\Users\softg\PycharmProjects\test\keraspp\keraspp\aicnn.py", line 25, in __init__
    model.build_model()
  File "C:\Users\softg\PycharmProjects\test\keraspp\keraspp\aicnn.py", line 49, in build_model
    model.cl_part = Model(x, z_cl)
  File "C:\Users\softg\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\network.py", line 316, in __setattr__
    'It looks like you are subclassing `Model` and you '
RuntimeError: It looks like you are subclassing `Model` and you forgot to call `super(YourClass, self).__init__()`. Always start with this line.

Process finished with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.