I'm look for tutorials on how to build a Tensorflow model that generates predictions from input, for example, generating sentences from a paragraph, then the loss is determined when compared to ground truth labels. Or generating a number of predictions for objects found in an image. The main idea is having undetermined number of predictions or labels.
I just want to know if is it possible to use tf.estimator.DNNClassifier with multiple different activation functions. I mean, could I use a DNNClassifier estimator which use different activation functions for different layers? For example, if I have a three layers model, could I use for the first layer a sigmoid function, for the second one a ReLu function and finally for the last one a tanh function? I would like to know if it isn't possible to do it …
I've trained a model and saved it in .h5 format. when I try loading it I received this error ValueError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_588/661726548.py in <module> 9 # returns a compiled model 10 # identical to the previous one ---> 11 reconstructed_model = keras.models.load_model("./custom_model.h5") ~\Anaconda3\lib\site-packages\keras\utils\traceback_utils.py in error_handler(*args, **kwargs) 65 except Exception as e: # pylint: disable=broad-except 66 filtered_tb = _process_traceback_frames(e.__traceback__) ---> 67 raise e.with_traceback(filtered_tb) from None 68 finally: 69 del filtered_tb ~\Anaconda3\lib\site-packages\keras\utils\generic_utils.py in class_and_config_for_serialized_keras_object(config, module_objects, custom_objects, printable_module_name) 560 …
I am using vats-vs-dogs data set where the subdirectories are not precreated. Only 1 folder with 25000 images. (cat.001.jpg.... etc then dog.342.jpg.... etc) all in one folder. There are no separate folders called /cats or /dogs. How to use tf.keras.utils.image_dataset_from_directory function in such case ? Do I need to explicitly compartmentalize all dogs in /dog and all cats into /cats and then do it ? img_height = 300 img_width = 300 training_dir = 'drive/MyDrive/training1/dog-cat-train/train' train_ds = tf.keras.utils.image_dataset_from_directory( training_dir, labels='inferred', label_mode='categorical', …
I`m training a siamese CNN to distinguish between pairs of images and though my train/val binary cross-entropy loss values show negative trend, implying some of the model parameters are being updated, I noticed that convolution kernels barely change while their biases change significantly tensorboard weights histogram image. Also, while loss value decreases, accuracy appears to be frozen for some epochs and then instantly shoots up accuracy and loss plots. Q1: If this is caused by vanishing gradient, why would it …
I'm learning about variational autoencoders and I've implemented a simple example in keras, model summary below. I've copied the loss function from one of Francois Chollet's blog posts and I'm getting really really negative losses. What am I missing here? Model: "model_1" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_1 (InputLayer) [(None, 224)] 0 __________________________________________________________________________________________________ encoding_flatten (Flatten) (None, 224) 0 input_1[0][0] __________________________________________________________________________________________________ encoding_layer_2 (Dense) (None, 256) 57600 encoding_flatten[0][0] __________________________________________________________________________________________________ encoding_layer_3 (Dense) (None, 128) 32896 encoding_layer_2[0][0] __________________________________________________________________________________________________ encoding_layer_4 …
I have created a keras model that takes 3 images as input, passes them to individual CNN backbone(mobilenet_v2) and fuse the results from 3 individual streams. These fused outputs further goes through a FCN and gives probability values for 10 classes. Now when i pass 3 images to my model using model.predict(), I am getting an output of 3x10 (list of 3 outputs with 10 values in each). Here is the network snapshot and here is the output *[[0.04718336 0.07464679 …
I have a CNN classification model that uses loss: binary cross entropy: optimizer_instance = Adam(learning_rate=learning_rate, decay=learning_rate / 200) model.compile(optimizer=optimizer_instance, loss='binary_crossentropy') We are saving the best model so the latest saved model is the one that achieved the best val_loss: es = EarlyStopping(monitor='val_loss', mode='min', verbose=0, patience=Config.LearningParameters.Patience) modelPath = modelFileFolder + Config.LearningParameters.ModelFileName checkpoint = keras.callbacks.ModelCheckpoint(modelPath , monitor='val_loss', save_best_only=True, save_weights_only=False, verbose=1) callbacks = [checkpoint,es] history = model.fit(x=training_generator, batch_size=Config.LearningParameters.Batch_size, epochs=Config.LearningParameters.Epochs, validation_data=validation_generator, callbacks=callbacks, verbose=1) on the course of the training the logs show that the …
I am training a VGG net on STL-10 dataset I am getting Top-5 validation accuracy about 98% and Top-1 validation accuracy about 83% But both the Top-1 and Top-5 Training accuracy is reaching 100% Does this mean that the network is over-fitting? Or not? Code:: def conv2d(inp,name,kshape,s): with tf.variable_scope(name) as scope: kernel = get_weights('weights',shape=kshape) conv = tf.nn.conv2d(inp,kernel,[1,s,s,1],'SAME') bias = get_bias('biases',shape=kshape[3]) preact = tf.nn.bias_add(conv,bias) convlayer = tf.nn.relu(preact,name=scope.name) return convlayer def maxpool(inp,name,k,s): return tf.nn.max_pool(inp,ksize=[1,k,k,1],strides=[1,s,s,1],padding='SAME',name=name) def loss(logits,labels): labels = tf.reshape(tf.cast(labels,tf.int64),[-1]) #print labels.get_shape().as_list(),logits.get_shape().as_list() cross_entropy …
I have a group of non zero sequences with different lengths and I am using Keras LSTM to model these sequences. I use Keras Tokenizer to tokenize (tokens start from 1). In order to make sequences have the same lengths, I use padding. An example of padding: # [0,0,0,0,0,10,3] # [0,0,0,0,10,3,4] # [0,0,0,10,3,4,5] # [10,3,4,5,6,9,8] In order to evaluate if the model is able to generalize, I use a validation set with 70/30 ratio. In the end of each epoch …
I am quite confused on the output of model.predict when after training I validate my model on around 6000 samples I use the following pseudo code: model.fit(...) predictions = model.predict(val_set) len(predictions) # == len(val_set) result: tensor array of shape=(len(tensor_array),14) (one prediction for each input sample) in production I currently use the following code to ocr image numbers: model = tf.keras.models.load_model('number_ocr_v2') def predict(list_images): global model print("length:") print(len(list_images)) #predictions = model.predict(list_images) # <- Same result predictions = model.predict_on_batch(list_images) print(len(predictions)) print(predictions) console Output: …
I have a system, described by a black-box (a fully connected neural network), that takes as input a signal in time (let's say something similar to a sine wave) and returns a single scalar as output. My goal is to find the optimum signal that maximizes/minimizes the output. As constraints, the time average of the signal must be kept constant and the minimum and maximum value of the signal must be within a specific range. I wonder what kind of …
I am currently training a few custom models that require about 12Gb GPU memory at the most. My setup has about 96Gb of GPU memory and python/Jupyter still manages to hog up all the gpu memory to the point that I get the Resource exhausted error thrown at me. I am stuck at this peculiar issue for a while and hence any help will be appreciated. Now, when loading a vgg based model similar to this: from keras.applications.vgg16 import VGG16 …
I have worked with a few GAN-like algorithms, but always with similar inputs and outputs. Being only a novice in deep learning, I often work by adapting an already existing Notebook, but today I have a more complex problem and I cannot find a similar example. For my algorithm I need to predict a curve, which is a list of floats (e.g. dimension 20x1), from two types of input data; a 2D image (e.g. a 16x16 normalized float array) and …
I'm working on a TensorFlow model, and I would like to have different logic in the model depending on the input. My question is if it's possible to have a "dispatch" layer in TensorFlow that depending on the input uses one model or another? Simplified example: Imagine your input has two fields a: int and b: Optional[int]. This means b can be defined or not. If b is not None you want to execute some layers, and if it's None …
I plan to build a CNN for face recognition using this Kaggle dataset. I tried building a model with a single hidden layer with 256 fully connected neurons, and it gave an accuracy of 45% after 55 epochs. Should I just set the no. of hidden layers (and the no. of neurons in the layers) as variables, and repeat the model evaluation process for various values of the variables to determine the optimum values? Or is there any other, more …
I'm working on ubuntu, and i'm trying to train my python model but i receive the following error Traceback (most recent call last): File "trial.py", line 2, in <module> import tensorflow as tf ImportError: No module named tensorflow I've tried to install tensorflow via pip install tensorfow and ensure being installed via the following command pip show tensor and this is the output Name: tensorflow Version: 2.6.2 Summary: TensorFlow is an open source machine learning framework for everyone. Home-page: https://www.tensorflow.org/ …
I am creating a custom Keras layer FConv2D(), and adding a weight in its build() function using the add_weight() method as suggested in official Keras tutorial for creating custom layers. def build(self, input_shape): shape = tf.TensorShape(input_shape).as_list() h = shape[1] w = shape[2] in_channels = shape[3] self.kernel = self.add_weight( shape=(h,w,in_channels,self.num_outputs), initializer="random_normal", trainable=True, ) super(FConv2D, self).build(input_shape) But when I print the summary of a single-layer model containing just this layer, the number of parameters in this layer is shown to be 0. …
I'm trying to develop a small network for the aerial cactus identification challenge. This is a binary classification challenge (0 no cactus, 1 is cactus), but my networks is always outputting 1. I have identified that the network always output values >= 0.5, so the sigmoid function outputs 1. However, I can't understand why. I built a simple network, which works when implemented with keras, but I'm trying to use tf.nn for learning purposes, but can't make it work My …