Categories
Misc

I m new to tensorflow and i need some help pls

I have a dataset that i downloaded from kaggle and it s in 4 folders trainA,trainB,testA,testB And i would like to put these image folders into a tf.data.dataset called DATA for example and i would like to call DATA[‘trainA’] for example to get the first folder thank you

submitted by /u/Jaded-Historian7036
[visit reddit] [comments]

Categories
Misc

Negative gradients when calculating GradCAM heatmap

I have a Segmentation network model trained for 2 classes and am able to see accurate results. But when using grad-cam for the heatmap, I am able to see good results for the last convolution layer for both the classes but have issues when trying to generate a heatmap for the second last convolution layer for one of the classes (the other class’s heatmap is working fine).

**Last 5 layers** convolution_layer(filters:8, kernel:3*3) convolution_transpose_layer(filters:2, kernel:2*2) convolution_layer(filters:2, kernel:3*3) convolution_layer(filters:10, kernel:1*1) activation_layer(softmax) 

The heatmap is empty because of all negative pooled gradients(due to mean from all the -ve gradients wrt Conv layer), resulting in negative values in pooled_grads*convolution_output on which relu is applied, giving all zeros.

What does it mean for GradCAM to be all negative?

Why is it that all channels in the convolution lead to a “negative” contribution to the true output class?

https://arxiv.org/pdf/2002.11434.pdf following this paper for heatmap for segmentation models.

submitted by /u/Ash_real
[visit reddit] [comments]

Categories
Misc

custom accuracy metric

Hi, I have been trying to implement a custom masked accuracy metric which does not consider the pad tokens (similar to the masked loss as shown here https://www.tensorflow.org/text/tutorials/nmt_with_attention). I have been trying to create a new subclass using the tf.keras. metrics.Metric, but I am very confused. Any leads would be really appreciated.

submitted by /u/Hour-Tie-7471
[visit reddit] [comments]

Categories
Misc

Neural Network getting 0 accuracy, and always predicting very high values

When I printed out the prediction, and the actual value side by side

[0.9785253] 6 [0.97852457] 5 [0.9785253] 6 [0.9785253] 5 [0.97848856] 6 [0.9785253] 7 [0.9785253] 5 [0.9785253] 7 

thats what it looked like, the value in bracket is the prediction, the other the actual one!

Have no clue why this is doing this, can you help please!!

submitted by /u/ME_I_AM_me
[visit reddit] [comments]

Categories
Misc

Gradients do not exist warning

I’ve tried to implement Yolov3 network by tf.keras, making it layer-by-layer. Then, I get outputs of layers 82, 94, 106, and pass them (and also – three training inputs with ground truth bounding boxes for every network stride) into Lambda layer to evaluate loss of net. However, when I try to train the network, I receive the warning: “WARNING:tensorflow:Gradients do not exist for variables [‘Layer_Conv_81/kernel:0’, ‘Layer_Conv_91/kernel:0’, ‘Layer_Batch_81/gamma:0’, ‘Layer_Batch_81/beta:0’, ‘Layer_Batch_91/gamma:0’, ‘Layer_Batch_91/beta:0’, ‘Output_1/kernel:0’, ‘Output_2/kernel:0’] when minimizing the loss. If you’re using `model.compile()`, did you forget to provide a `loss`argument?”

I’ve checked the sequence of layers – there are no unconnected ones, I have the loss function. What else could go wrong?

Brief version of code here:

def MakeYoloMainStructure(): inputImage = Input(shape=(IMAGE_SIDES[0], IMAGE_SIDES[1], 3), name='Main_Input') # Start placing layers layer1_1 = Conv2D(32, (3,3), strides=(1,1), use_bias=False, padding='same', name='Layer_Conv_1')(inputImage) layer1_2 = BatchNormalization(epsilon=eps, name='Layer_Batch_1')(layer1_1) layer1_3 = LeakyReLU(alpha=alp, name='Layer_Leaky_1')(layer1_2) # Start placing adding layers # Layer 1 - 64/1 layer2_1 = ZeroPadding2D(((1,0),(1,0)), name='Layer_ZeroPad_2')(layer1_3) layer2_2 = Conv2D(64, (3,3), strides=(2,2), use_bias=False, padding='valid', name='Layer_Conv_2')(layer2_1) layer2_3 = BatchNormalization(epsilon=eps, name='Layer_Batch_2')(layer2_2) layer2_4 = LeakyReLU(alpha=alp, name='Layer_Leaky_2')(layer2_3) ... layer80_2 = BatchNormalization(epsilon=eps, name='Layer_Batch_80')(layer80_1) layer80_3 = LeakyReLU(alpha=alp, name='Layer_Leaky_80')(layer80_2) layer81_1 = Conv2D(1024, (3,3), strides=(1,1), use_bias=False, padding='same', name='Layer_Conv_81')(layer80_3) # From this layer we make fork for first output (!) layer81_2 = BatchNormalization(epsilon=eps, name='Layer_Batch_81')(layer81_1) layer81_3 = LeakyReLU(alpha=alp, name='Layer_Leaky_81')(layer81_2) layer82_1 = Conv2D(3*6, (1,1), strides=(1,1), use_bias=False, padding='same', name='Output_1')(layer81_3) # FIRST output layer (!) layer84_1 = layer80_3 layer85_1 = Conv2D(256, (1,1), strides=(1,1), use_bias=False, padding='same', name='Layer_Conv_83')(layer84_1) ..... layer106_1 = Conv2D(3*6, (1,1), strides=(1,1), use_bias=False, padding='same', name='Output_3')(layer105_3) # THIRD output layer (!) # Net structure is completed yoloBoneModel = Model(inputImage, [layer82_1, layer94_1, layer106_1]) return yoloBoneModel def MakeYoloTrainStructure(yoloBoneModel): gridInput_all = [Input(shape=(GRID_SIDES[1], GRID_SIDES[1], 3, 6), name='Grid_Input_1'), Input(shape=(GRID_SIDES[2], GRID_SIDES[2], 3, 6), name='Grid_Input_2'), Input(shape=(GRID_SIDES[3], GRID_SIDES[3], 3, 6), name='Grid_Input_3')] layer_loss = Lambda(GetLoss, output_shape=(1,), name='GetLoss', arguments={'threshold': thresh})([*yoloBoneModel.output, *gridInput_all]) yoloTrainModel = Model([yoloBoneModel.input, *gridInput_all], layer_loss) return yoloTrainModel def GetLoss(args, threshold=0.5): modelOutputs = args[:3] checkInputs = args[3:] # ...... # Numerous manipulations to get loss of objects detection # ...... return loss def GetDataGenerator(batches): # Here I get image and ground truth Bounding Boxes data yield [imageData, *trueBoxes], np.zeros(batches) def main(): boneModel = MakeYoloMainStructure() trainModel = MakeYoloTrainStructure(boneModel) trainModel.compile(optimizer=Adam(lr=1e-3), loss={'GetLoss': lambda gridInput_all, y_pred: y_pred}, run_eagerly=True) batchSize = 32 trainModel.fit(GetDataGenerator(batchSize), steps_per_epoch=2000//batchSize, epochs=50, initial_epoch=0) 

submitted by /u/Nymfeparakit
[visit reddit] [comments]

Categories
Misc

How to load a model after it’s been saved?

How to load a model after it's been saved?

Tried using this for reference but it wasn’t working. Saving the model seems to work perfectly fine. Screenshots go in this order: 1. Code that trains and saves the model. 2. what the saved model looks like in the file directory. 3. Code that should load the model back and then test it. 4. Error message received when load/test code is run. How do I properly load my model back so it can be evaluated? Or is it that I’m improperly saving it?

1. Train and Save Code

2. File Directory (Saving every 100 epochs)

3. Load and Test Code

4. Console Error from 3.

submitted by /u/Kapooshi
[visit reddit] [comments]

Categories
Misc

Training TensorFlow models with HUGE datasets

submitted by /u/AM_DS
[visit reddit] [comments]

Categories
Misc

using ROCm for tensorflow on RX 6000 series radeon cards.

Sorry if this was asked recently. I used google to search for this and pretty much only got old information. I know recently rdna 2 is supposed to work with ROCm but no one benchmarks the results.

I am looking to buy a new laptop soon and was hoping to get something in the “ultra portable” category with good battery life. Something with a 6800U or 6900HS. I had not been planning on getting one with a discrete gpu but the new Asus Zephyrus 14 has a 6800S, is fairly small considering, gets 8 to 10 hours on battery. Might get a lenovo Z13 if the price is right when it releases.

I mostly just ssh into my desktop at home so I am not buying the laptop specifically for deep learning but I cant find anything I quite want in the laptop space with a 3060/3070. Obviously I would only do small test type work if I ever have to run it on the laptop and cpu training is possible, but would a 6800S gpu or maybe even the 680m onboard graphics train faster than the cpu?

submitted by /u/ObsidianAvenger
[visit reddit] [comments]

Categories
Misc

How to create a layer without an Input.

Hi,

In deep rl algorithm like PPO, a continuous stochastic policy is represented by Normal Distribution. For this the recommended way of creating a Normal Distribution is to get the mean by passing the state through NN and then using a state independent layer to predict log_std. This layer which predicts log_std should be trainable using backprop just like biases. So how to create this layer in tensorflow 2.

submitted by /u/Better-Ad8608
[visit reddit] [comments]

Categories
Misc

TF 1.x with CUDA 11.x

How can I install TF 1.x with CUDA 11.x with GPU support (for RTX 3xxx series)? All tutorials are outdated today. Wanna run a Mask R-CNN. Even the one with TF 2.x support, doesnt work with CUDA 11.x, rather than with CUDA 10.x

submitted by /u/giakou4
[visit reddit] [comments]