Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from tensorflow.python.keras import models
- from tensorflow.python.keras import layers
- from tensorflow.python.keras import backend as K
- inp = layers.Input(shape=(10, 20,))
- conv = layers.Conv1D(filters=10, kernel_size=2)(inp)
- pool = layers.GlobalMaxPool1D()(conv)
- output = layers.Dense(1, activation="sigmoid")(pool)
- m = models.Model(inp, output)
- m.summary()
- m.compile(optimizer="adam", loss="binary_crossentropy")
- m.fit(x=np.random.randn(100, 10, 20), y=np.random.randn(100))
- loss = K.mean(m.output)
- grads = K.gradients(loss, m.input)[0]
- f = K.function([m.input], [grads])
- print(f([np.random.randn(10, 20)]))
- import tensorflow as tf
- import sys
- from tensorflow.python import keras
- print(tf.__version__)
- print(keras.__version__)
- print(sys.version)
- 1.12.0
- 2.1.6-tf
- 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 14:01:38)
- [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
- 2019-04-19 17:00:58.249788: F ./tensorflow/core/util/tensor_format.h:420] Check failed: index >= 0 && index < dimension_attributes.size() Invalid index from the dimension: 3, 0, C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement