keras

Patch based image training and combine their probability from an image

被刻印的时光 ゝ 提交于 2021-02-11 13:00:15
问题 Firstly, I have implemented a simple VGG16 network for image classification. model = keras.applications.vgg16.VGG16(include_top = False, weights = None, input_shape = (32,32,3), pooling = 'max', classes = 10) Whose input shape is 32 x 32 . Now, I am trying to implement a patch-based neural network . The main idea is, from the input image, extract 4 image patch like this image, and train the extracted patch image( resizing to 32 x 32 as it is input shape of our model) finally, combine their

keras LSTM model - a tf 1.15 equivalent that works with tflite

喜夏-厌秋 提交于 2021-02-11 12:44:49
问题 TLDR : How to implement this model using tf.lite.experimental.nn.TFLiteLSTMCell, tf.lite.experimental.nn.dynamic_rnn instead keras.layers.LSTM ? I have this network in keras: inputs = keras.Input(shape=(1, 52)) state_1_h = keras.Input(shape=(200,)) state_1_c = keras.Input(shape=(200,)) x1, state_1_h_out, state_1_c_out = layers.LSTM(200, return_sequences=True, input_shape=(sequence_length, 52), return_state=True)(inputs, initial_state=[state_1_h, state_1_c]) output = layers.Dense(13)(x1) model

Should I be using tf.keras or keras in 2020?

馋奶兔 提交于 2021-02-11 12:42:48
问题 A while back I read this post on PyImageSearch and was satisfied enough to switch completely to tf.keras . But since then I noticed the Keras website got an overhaul and seems to be expanding on its ambitions. So I'm a bit confused. Is it still true that "the latest release of the keras package (v2.3.0) will be the last release to support multiple backends and feature updates. Moving forward, the keras package will receive only bug fixes." from PyImageSearch? If I stick with tf.keras could I

Large data quantities in keras model.predict

守給你的承諾、 提交于 2021-02-11 12:41:05
问题 I have a CNN that I define like this: inputs = keras.Input(shape=(1024,1)) x=inputs # 1st convolutional block x = keras.layers.Conv1D(16, kernel_size=(3), name='Conv_1')(x) x = keras.layers.LeakyReLU(0.1)(x) x = keras.layers.MaxPool1D((2), name='MaxPool_1')(x) x = keras.layers.Flatten(name='Flatten')(x) # Classifier x = keras.layers.Dense(64, name='Dense_1')(x) x = keras.layers.ReLU(name='ReLU_dense_1')(x) x = keras.layers.Dropout(0.2)(x) x = keras.layers.Dense(64, name='Dense_2')(x) x =

Why doesn't the Adadelta optimizer decay the learning rate?

倖福魔咒の 提交于 2021-02-11 12:32:07
问题 I have initialised an Adadelta optimizer in Keras (using Tensorflow backend) and assigned it to a model: my_adadelta = keras.optimizers.Adadelta(learning_rate=0.01, rho=0.95) my_model.compile(optimizer=my_adadelta, loss="binary_crossentropy") During training, I am using a callback to print the learning rate after every epoch: class LRPrintCallback(Callback): def on_epoch_end(self, epoch, logs=None): lr = self.model.optimizer.lr print(K.eval(lr)) However, this prints the same (initial)

How to implement gradient ascent in a Keras DQN

落爺英雄遲暮 提交于 2021-02-11 12:30:01
问题 Have built a Reinforcement Learning DQN with variable length sequences as inputs, and positive and negative rewards calculated for actions. Some problem with my DQN model in Keras means that although the model runs, average rewards over time decrease, over single and multiple cycles of epsilon. This does not change even after significant period of training. My thinking is that this is due to using MeanSquareError in Keras as the Loss function (minimising error). So I am trying to implement

How to implement gradient ascent in a Keras DQN

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 12:27:04
问题 Have built a Reinforcement Learning DQN with variable length sequences as inputs, and positive and negative rewards calculated for actions. Some problem with my DQN model in Keras means that although the model runs, average rewards over time decrease, over single and multiple cycles of epsilon. This does not change even after significant period of training. My thinking is that this is due to using MeanSquareError in Keras as the Loss function (minimising error). So I am trying to implement

How do I build a TFmodel from NumPy array files?

家住魔仙堡 提交于 2021-02-11 12:19:54
问题 I have a dir with NumPy array files: bias1.npy, kernel1.npy, bias2.npy, kernel2.npy . How can I build a TF model that uses those arrays as kernels and biases of layers? 回答1: To avoid confusion bias matrix for the consistency of the numpy file is the 2D matrix with one column. This post shows how did I reproduce tf's model based on the numpy weights and biases. class NumpyInitializer(tf.keras.initializers.Initializer): # custom class converting numpy arrays to tf's initializers # used to

Keras Deploy for Tensorflow.js Usage

帅比萌擦擦* 提交于 2021-02-11 12:05:04
问题 I need to be able to deploy a keras model for Tensorflow.js prediction, but the Firebase docs only seem to support a TFLite object, which tf.js cannot accept. Tf.js appears to accept JSON files for loading (loadGraphModel() / loadLayersModel() ), but not a keras SavedModel (.pb + /assets + /variables). How can I attain this goal? Note for the Tensorflow.js portion: There are a lot of pointers to the tfjs_converter, but the closest API function offered to what I'm looking for is the

Can not squeeze dim[1], expected a dimension of 1, got 5

。_饼干妹妹 提交于 2021-02-11 09:41:29
问题 I tried different solutions but still facing the issue. Actually I am new in Ml/DL (python). In which case we face this error "Can not squeeze dim1, expected a dimension of 1, got 5"? Please help me here, what I am doing wrong here and what is correct Here is InvalidArgumentError Traceback (most recent call last) --------------------------------------------------------------------------- <ipython-input-9-0826122252c2> in <module>() 98 model.summary() 99 model.compile(loss='sparse_categorical