keras 0.2.0__py3.5.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. EGG-INFO/PKG-INFO +11 -0
  2. EGG-INFO/SOURCES.txt +57 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/requires.txt +6 -0
  5. EGG-INFO/top_level.txt +2 -0
  6. EGG-INFO/zip-safe +1 -0
  7. keras/__init__.py +15 -0
  8. keras/__pycache__/__init__.cpython-35.pyc +0 -0
  9. keras/__pycache__/activations.cpython-35.pyc +0 -0
  10. keras/__pycache__/callbacks.cpython-35.pyc +0 -0
  11. keras/__pycache__/constraints.cpython-35.pyc +0 -0
  12. keras/__pycache__/initializations.cpython-35.pyc +0 -0
  13. keras/__pycache__/models.cpython-35.pyc +0 -0
  14. keras/__pycache__/objectives.cpython-35.pyc +0 -0
  15. keras/__pycache__/optimizers.cpython-35.pyc +0 -0
  16. keras/__pycache__/regularizers.cpython-35.pyc +0 -0
  17. keras/activations.py +44 -0
  18. keras/callbacks.py +293 -0
  19. keras/constraints.py +48 -0
  20. keras/datasets/__init__.py +0 -0
  21. keras/datasets/__pycache__/__init__.cpython-35.pyc +0 -0
  22. keras/datasets/__pycache__/cifar.cpython-35.pyc +0 -0
  23. keras/datasets/__pycache__/cifar10.cpython-35.pyc +0 -0
  24. keras/datasets/__pycache__/cifar100.cpython-35.pyc +0 -0
  25. keras/datasets/__pycache__/data_utils.cpython-35.pyc +0 -0
  26. keras/datasets/__pycache__/imdb.cpython-35.pyc +0 -0
  27. keras/datasets/__pycache__/mnist.cpython-35.pyc +0 -0
  28. keras/datasets/__pycache__/reuters.cpython-35.pyc +0 -0
  29. keras/datasets/cifar.py +22 -0
  30. keras/datasets/cifar10.py +31 -0
  31. keras/datasets/cifar100.py +28 -0
  32. keras/datasets/data_utils.py +50 -0
  33. keras/datasets/imdb.py +66 -0
  34. keras/datasets/mnist.py +23 -0
  35. keras/datasets/reuters.py +148 -0
  36. keras/initializations.py +89 -0
  37. keras/layers/__init__.py +0 -0
  38. keras/layers/__pycache__/__init__.cpython-35.pyc +0 -0
  39. keras/layers/__pycache__/advanced_activations.cpython-35.pyc +0 -0
  40. keras/layers/__pycache__/containers.cpython-35.pyc +0 -0
  41. keras/layers/__pycache__/convolutional.cpython-35.pyc +0 -0
  42. keras/layers/__pycache__/core.cpython-35.pyc +0 -0
  43. keras/layers/__pycache__/embeddings.cpython-35.pyc +0 -0
  44. keras/layers/__pycache__/noise.cpython-35.pyc +0 -0
  45. keras/layers/__pycache__/normalization.cpython-35.pyc +0 -0
  46. keras/layers/__pycache__/recurrent.cpython-35.pyc +0 -0
  47. keras/layers/advanced_activations.py +137 -0
  48. keras/layers/containers.py +318 -0
  49. keras/layers/convolutional.py +504 -0
  50. keras/layers/core.py +963 -0
  51. keras/layers/embeddings.py +153 -0
  52. keras/layers/noise.py +57 -0
  53. keras/layers/normalization.py +117 -0
  54. keras/layers/recurrent.py +837 -0
  55. keras/models.py +733 -0
  56. keras/objectives.py +67 -0
  57. keras/optimizers.py +228 -0
  58. keras/preprocessing/__init__.py +0 -0
  59. keras/preprocessing/__pycache__/__init__.cpython-35.pyc +0 -0
  60. keras/preprocessing/__pycache__/image.cpython-35.pyc +0 -0
  61. keras/preprocessing/__pycache__/sequence.cpython-35.pyc +0 -0
  62. keras/preprocessing/__pycache__/text.cpython-35.pyc +0 -0
  63. keras/preprocessing/image.py +251 -0
  64. keras/preprocessing/sequence.py +124 -0
  65. keras/preprocessing/text.py +176 -0
  66. keras/regularizers.py +84 -0
  67. keras/utils/__init__.py +0 -0
  68. keras/utils/__pycache__/__init__.cpython-35.pyc +0 -0
  69. keras/utils/__pycache__/generic_utils.cpython-35.pyc +0 -0
  70. keras/utils/__pycache__/io_utils.cpython-35.pyc +0 -0
  71. keras/utils/__pycache__/layer_utils.cpython-35.pyc +0 -0
  72. keras/utils/__pycache__/np_utils.cpython-35.pyc +0 -0
  73. keras/utils/__pycache__/test_utils.cpython-35.pyc +0 -0
  74. keras/utils/__pycache__/theano_utils.cpython-35.pyc +0 -0
  75. keras/utils/__pycache__/visualize_util.cpython-35.pyc +0 -0
  76. keras/utils/generic_utils.py +133 -0
  77. keras/utils/io_utils.py +71 -0
  78. keras/utils/layer_utils.py +129 -0
  79. keras/utils/np_utils.py +53 -0
  80. keras/utils/test_utils.py +27 -0
  81. keras/utils/theano_utils.py +44 -0
  82. keras/utils/visualize_util.py +41 -0
  83. keras/wrappers/__init__.py +0 -0
  84. keras/wrappers/__pycache__/__init__.cpython-35.pyc +0 -0
  85. keras/wrappers/__pycache__/scikit_learn.cpython-35.pyc +0 -0
  86. keras/wrappers/scikit_learn.py +266 -0
  87. tests/__init__.py +0 -0
  88. tests/__pycache__/__init__.cpython-35.pyc +0 -0
  89. tests/manual/__init__.py +0 -0
  90. tests/manual/__pycache__/__init__.cpython-35.pyc +0 -0
  91. tests/manual/__pycache__/check_autoencoder.cpython-35.pyc +0 -0
  92. tests/manual/__pycache__/check_callbacks.cpython-35.pyc +0 -0
  93. tests/manual/__pycache__/check_constraints.cpython-35.pyc +0 -0
  94. tests/manual/__pycache__/check_masked_recurrent.cpython-35.pyc +0 -0
  95. tests/manual/__pycache__/check_model_utils.cpython-35.pyc +0 -0
  96. tests/manual/__pycache__/check_save_weights.cpython-35.pyc +0 -0
  97. tests/manual/__pycache__/check_wrappers.cpython-35.pyc +0 -0
  98. tests/manual/__pycache__/check_yaml.cpython-35.pyc +0 -0
  99. tests/manual/check_autoencoder.py +134 -0
  100. tests/manual/check_callbacks.py +236 -0
  101. tests/manual/check_constraints.py +100 -0
  102. tests/manual/check_masked_recurrent.py +130 -0
  103. tests/manual/check_model_utils.py +44 -0
  104. tests/manual/check_save_weights.py +40 -0
  105. tests/manual/check_wrappers.py +126 -0
  106. tests/manual/check_yaml.py +101 -0
@@ -0,0 +1,101 @@
1
+ from __future__ import absolute_import
2
+ from __future__ import print_function
3
+ import numpy as np
4
+
5
+ from keras.utils.test_utils import get_test_data
6
+ from keras.preprocessing import sequence
7
+ from keras.optimizers import SGD, RMSprop, Adagrad
8
+ from keras.utils import np_utils
9
+ from keras.models import Sequential, Graph
10
+ from keras.layers.core import Dense, Dropout, Activation, Merge
11
+ from keras.layers.embeddings import Embedding
12
+ from keras.layers.recurrent import LSTM, GRU
13
+ from keras.datasets import imdb
14
+ from keras.models import model_from_yaml
15
+
16
+ '''
17
+ This is essentially the IMDB test. Deserialized models should yield
18
+ the same config as the original one.
19
+ '''
20
+
21
+ max_features = 10000
22
+ maxlen = 100
23
+ batch_size = 32
24
+
25
+ (X_train, y_train), (X_test, y_test) = imdb.load_data(nb_words=max_features, test_split=0.2)
26
+
27
+ X_train = sequence.pad_sequences(X_train, maxlen=maxlen)
28
+ X_test = sequence.pad_sequences(X_test, maxlen=maxlen)
29
+
30
+ model = Sequential()
31
+ model.add(Embedding(max_features, 128))
32
+ model.add(LSTM(128, 128))
33
+ model.add(Dropout(0.5))
34
+ model.add(Dense(128, 1, W_regularizer='identity', b_constraint='maxnorm'))
35
+ model.add(Activation('sigmoid'))
36
+
37
+ model.get_config(verbose=1)
38
+
39
+ #####################################
40
+ # save model w/o parameters to yaml #
41
+ #####################################
42
+
43
+ yaml_no_params = model.to_yaml()
44
+
45
+ no_param_model = model_from_yaml(yaml_no_params)
46
+ no_param_model.get_config(verbose=1)
47
+
48
+ ######################################
49
+ # save multi-branch sequential model #
50
+ ######################################
51
+
52
+ seq = Sequential()
53
+ seq.add(Merge([model, model], mode='sum'))
54
+ seq.get_config(verbose=1)
55
+ merge_yaml = seq.to_yaml()
56
+ merge_model = model_from_yaml(merge_yaml)
57
+
58
+ large_model = Sequential()
59
+ large_model.add(Merge([seq,model], mode='concat'))
60
+ large_model.get_config(verbose=1)
61
+ large_model.to_yaml()
62
+
63
+ ####################
64
+ # save graph model #
65
+ ####################
66
+
67
+ X = np.random.random((100, 32))
68
+ X2 = np.random.random((100, 32))
69
+ y = np.random.random((100, 4))
70
+ y2 = np.random.random((100,))
71
+
72
+ (X_train, y_train), (X_test, y_test) = get_test_data(nb_train=1000, nb_test=200, input_shape=(32,),
73
+ classification=False, output_shape=(4,))
74
+
75
+ graph = Graph()
76
+
77
+ graph.add_input(name='input1', ndim=2)
78
+
79
+ graph.add_node(Dense(32, 16), name='dense1', input='input1')
80
+ graph.add_node(Dense(32, 4), name='dense2', input='input1')
81
+ graph.add_node(Dense(16, 4), name='dense3', input='dense1')
82
+
83
+ graph.add_output(name='output1', inputs=['dense2', 'dense3'], merge_mode='sum')
84
+ graph.compile('rmsprop', {'output1': 'mse'})
85
+
86
+ graph.get_config(verbose=1)
87
+
88
+ history = graph.fit({'input1': X_train, 'output1': y_train}, nb_epoch=10)
89
+ original_pred = graph.predict({'input1': X_test})
90
+
91
+ graph_yaml = graph.to_yaml()
92
+ graph.save_weights('temp.h5', overwrite=True)
93
+
94
+ reloaded_graph = model_from_yaml(graph_yaml)
95
+ reloaded_graph.load_weights('temp.h5')
96
+ reloaded_graph.get_config(verbose=1)
97
+
98
+ reloaded_graph.compile('rmsprop', {'output1': 'mse'})
99
+ new_pred = reloaded_graph.predict({'input1': X_test})
100
+
101
+ assert(np.sum(new_pred['output1'] - original_pred['output1']) == 0)