keras-layer

math_ops.floor equivalent in Keras

戏子无情 提交于 2019-12-01 21:21:19
I'm trying to implement a custom layer in Keras where I need to convert a tensor of floats [a, 1+a) to a binary tensor for masking. I can see that Tensorflow has a floor function that can do that, but Keras doesn't seem to have it in keras.backend . Any idea how I can do this? As requested by OP, I will mention the answer I gave in my comment and elaborate more: Short answer: you won't encounter any major problems if you use tf.floor() . Long answer: Using Keras backend functions (i.e. keras.backend.* ) is necessary in those cases when 1) there is a need to pre-process or augment the argument

How to implement Merge from Keras.layers

坚强是说给别人听的谎言 提交于 2019-12-01 21:05:24
I have been trying to merge the following sequential models but haven't been able to. Could somebody please point out my mistake, thank you. The code compiles while using"merge" but give the following error "TypeError: 'module' object is not callable" However it doesn't even compile while using "Merge" I am using keras version 2.2.0 and python 3.6 from keras.layers import merge def linear_model_combined(optimizer='Adadelta'): modela = Sequential() modela.add(Flatten(input_shape=(100, 34))) modela.add(Dense(1024)) modela.add(Activation('relu')) modela.add(Dense(512)) modelb = Sequential()

Multi-dimensional input layers in Keras

强颜欢笑 提交于 2019-12-01 13:42:10
Which layers in Keras can be used as a first layer to take in multi-dimensional features? I'd like to use a dense layer with 1275 features that have 11 channels, but it looks like I can only use convolutional layers or recurrent layers for features of 2 or more dimensions. Is that correct? As far as I know you are correct, but you could reshape your data to have 1275 * 11 features and then run a dense layer on top of it. There is a Reshape Layer ( https://keras.io/layers/core/#reshape ) and a Flatten Layer ( https://keras.io/layers/core/#flatten ). For a dense layer you normally flatten your

Multi-dimensional input layers in Keras

我是研究僧i 提交于 2019-12-01 09:46:55
问题 Which layers in Keras can be used as a first layer to take in multi-dimensional features? I'd like to use a dense layer with 1275 features that have 11 channels, but it looks like I can only use convolutional layers or recurrent layers for features of 2 or more dimensions. Is that correct? 回答1: As far as I know you are correct, but you could reshape your data to have 1275 * 11 features and then run a dense layer on top of it. There is a Reshape Layer (https://keras.io/layers/core/#reshape)

What does the “[0][0]” of the layers connected to in keras model.summary mean?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 08:07:38
As is depicted in the following table, what does the [0][0] of the input_1[0][0] mean? __________________________________________________ Layer (type) Output Shape Param # Connected to =================================================================== input_1 (InputLayer) (None, 1) 0 ___________________________________________________________________ dropout_1 (Dropout) (None, 1) 0 input_1[0][0] ___________________________________________________________________ dropout_2 (Dropout) (None, 1) 0 input_1[0][0] =================================================================== Total params: 0

Keras give input to intermediate layer and get final output

大憨熊 提交于 2019-12-01 06:46:38
My model is a simple fully connected network like this: inp=Input(shape=(10,)) d=Dense(64, activation='relu')(inp) d=Dense(128,activation='relu')(d) d=Dense(256,activation='relu')(d) #want to give input here, layer3 d=Dense(512,activation='relu')(d) d=Dense(1024,activation='relu')(d) d=Dense(128,activation='linear')(d) So, after saving the model I want to give input to layer 3. What I am doing right now is this: model=load_model('blah.h5') #above described network print(temp_input.shape) #(16,256), which is equal to what I want to give index=3 intermediate_layer_model = Model(inputs=temp_input

Keras give input to intermediate layer and get final output

二次信任 提交于 2019-12-01 05:00:31
问题 My model is a simple fully connected network like this: inp=Input(shape=(10,)) d=Dense(64, activation='relu')(inp) d=Dense(128,activation='relu')(d) d=Dense(256,activation='relu')(d) #want to give input here, layer3 d=Dense(512,activation='relu')(d) d=Dense(1024,activation='relu')(d) d=Dense(128,activation='linear')(d) So, after saving the model I want to give input to layer 3. What I am doing right now is this: model=load_model('blah.h5') #above described network print(temp_input.shape) #(16

ValueError: Unknown layer: CapsuleLayer

一个人想着一个人 提交于 2019-12-01 02:52:44
问题 I have defined a custom layer named CapsuleLayer . The actual model has been defined in a separate class. I have loaded the weights into the actual model and have saved the model in an .h5 file. However when I try to load the model using load_model(filepath) I get the error ValueError: Unknown layer: CapsuleLayer How can I incorporate the custom layer into my model while loading the saved model. 回答1: C.f. Keras FAQ, "Handling custom layers (or other custom objects) in saved models": If the

What does the “[0][0]” of the layers connected to in keras model.summary mean?

こ雲淡風輕ζ 提交于 2019-11-30 17:51:26
问题 As is depicted in the following table, what does the [0][0] of the input_1[0][0] mean? __________________________________________________ Layer (type) Output Shape Param # Connected to =================================================================== input_1 (InputLayer) (None, 1) 0 ___________________________________________________________________ dropout_1 (Dropout) (None, 1) 0 input_1[0][0] ___________________________________________________________________ dropout_2 (Dropout) (None, 1)

Keras reset layer numbers

断了今生、忘了曾经 提交于 2019-11-30 16:03:07
Keras assigns incrementing ID numbers to layers of the same type, e.g. max_pooling1d_7 , max_pooling1d_8 , max_pooling1d_9 ,etc. Each iteration of my code constructs a new model, starting with model = Sequential() and then adding layers via model.add() . Even though each cycle creates a new Sequential object, the layer ID numbers continue incrementing from the previous cycle. Since my process is long-running these ID numbers can grow very large. I am concerned that this could cause some problem. Why are the IDs not reset by model = Sequential() ? Is there a way to reset them? After each cycle