keras

Tensorflow compatibility with Keras

淺唱寂寞╮ 提交于 2021-02-20 18:47:00
问题 I am using Python 3.6 and Tensorflow 2.0, and have some Keras codes: import keras from keras.models import Sequential from keras.layers import Dense model = Sequential() model.add(Dense(1)) model.compile(optimizer='adam',loss='mean_squared_error',metrics=['accuracy']) However I got the error: "Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow " when trying to run it. I checked on https://keras.io/, it says Keras was built on Tensorflow 2.0. So I am

How to get the batch size inside lambda layer

二次信任 提交于 2021-02-20 09:01:21
问题 I'm trying to implement a layer (via lambda layer) which is doing the following numpy procedure: def func(x, n): return np.concatenate((x[:, :n], np.tile(x[:, n:].mean(axis = 0), (x.shape[0], 1))), axis = 1) I'm stuck because I don't know how to get the size of the first dimension of x (which is the batch size). The backend function int_shape(x) returns (None, ...) . So, if I know the batch_size, the corresponding Keras procedure would be: def func(x, n): return K.concatenate([x[:, :n], K

Can't change activations in existing Keras model

梦想与她 提交于 2021-02-20 05:44:10
问题 I have a normal VGG16 model with relu activations, i.e. def VGG_16(weights_path=None): model = Sequential() model.add(ZeroPadding2D((1, 1),input_shape=(3, 224, 224))) model.add(Convolution2D(64, 3, 3, activation='relu')) model.add(ZeroPadding2D((1, 1))) model.add(Convolution2D(64, 3, 3, activation='relu')) model.add(MaxPooling2D((2, 2), strides=(2, 2))) [...] model.add(Flatten()) model.add(Dense(4096, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(4096, activation='relu')) model

Errors when training my saved tensorflow model

与世无争的帅哥 提交于 2021-02-20 05:14:28
问题 I'm trying to build a custom keras model whith the subclassing API but I get some errors when I load a previous instance of my model and I try to train it : Here is the class of my model, it has 3 inputs and 1 output : import tensorflow as tf spec1 = tf.TensorSpec(shape=(1,40,5,1)) spec2 = tf.TensorSpec(shape=(1,3)) class Conv_Rnn_model(tf.keras.Model): def __init__(self): # super() permet d'appeler le constructeur de la classe mère dans la classe fille # permet égalemet de résoudre le

Errors when training my saved tensorflow model

∥☆過路亽.° 提交于 2021-02-20 05:14:25
问题 I'm trying to build a custom keras model whith the subclassing API but I get some errors when I load a previous instance of my model and I try to train it : Here is the class of my model, it has 3 inputs and 1 output : import tensorflow as tf spec1 = tf.TensorSpec(shape=(1,40,5,1)) spec2 = tf.TensorSpec(shape=(1,3)) class Conv_Rnn_model(tf.keras.Model): def __init__(self): # super() permet d'appeler le constructeur de la classe mère dans la classe fille # permet égalemet de résoudre le

Errors when training my saved tensorflow model

两盒软妹~` 提交于 2021-02-20 05:12:51
问题 I'm trying to build a custom keras model whith the subclassing API but I get some errors when I load a previous instance of my model and I try to train it : Here is the class of my model, it has 3 inputs and 1 output : import tensorflow as tf spec1 = tf.TensorSpec(shape=(1,40,5,1)) spec2 = tf.TensorSpec(shape=(1,3)) class Conv_Rnn_model(tf.keras.Model): def __init__(self): # super() permet d'appeler le constructeur de la classe mère dans la classe fille # permet égalemet de résoudre le

Errors when training my saved tensorflow model

浪尽此生 提交于 2021-02-20 05:12:42
问题 I'm trying to build a custom keras model whith the subclassing API but I get some errors when I load a previous instance of my model and I try to train it : Here is the class of my model, it has 3 inputs and 1 output : import tensorflow as tf spec1 = tf.TensorSpec(shape=(1,40,5,1)) spec2 = tf.TensorSpec(shape=(1,3)) class Conv_Rnn_model(tf.keras.Model): def __init__(self): # super() permet d'appeler le constructeur de la classe mère dans la classe fille # permet égalemet de résoudre le

how i can create 3d input / 3d output Convolution model with keras?

限于喜欢 提交于 2021-02-20 05:12:34
问题 I have a bit question i couldnt solve. I wanna implement CNN model with fully-connected MLP to my protein database which has 2589 proteins. Each protein has 1287 rows and 69 columns as input and and 1287 rows and 8 columns as output. Actually there was 1287x1 output, but i used one hot encoding for class labels to use crossentropy loss in my model. Also i want if we consider as image i have an 3d matrix ** X_train = (2589, 1287, 69) for input** and y_train =(2589, 1287, 8) output , i mean

how i can create 3d input / 3d output Convolution model with keras?

一个人想着一个人 提交于 2021-02-20 05:12:34
问题 I have a bit question i couldnt solve. I wanna implement CNN model with fully-connected MLP to my protein database which has 2589 proteins. Each protein has 1287 rows and 69 columns as input and and 1287 rows and 8 columns as output. Actually there was 1287x1 output, but i used one hot encoding for class labels to use crossentropy loss in my model. Also i want if we consider as image i have an 3d matrix ** X_train = (2589, 1287, 69) for input** and y_train =(2589, 1287, 8) output , i mean

how i can create 3d input / 3d output Convolution model with keras?

天涯浪子 提交于 2021-02-20 05:09:30
问题 I have a bit question i couldnt solve. I wanna implement CNN model with fully-connected MLP to my protein database which has 2589 proteins. Each protein has 1287 rows and 69 columns as input and and 1287 rows and 8 columns as output. Actually there was 1287x1 output, but i used one hot encoding for class labels to use crossentropy loss in my model. Also i want if we consider as image i have an 3d matrix ** X_train = (2589, 1287, 69) for input** and y_train =(2589, 1287, 8) output , i mean