tensorflow

Visualizing the Gradients as heat map in Tensorflow 2

隐身守侯 提交于 2021-02-10 05:35:49
问题 I am working on a task to generate heatmap by guided backpropagation. I have overridden the original Relu and obtained the gradient for each parameter. However, I am not sure what should I do next. Your assistance is appreciated! Thank you! Here is my code: I first use @tf.RegisterGradient("GuidedRelu") like: def _GuidedReluGrad(op, grad): gate_f = tf.cast(op.outputs[0] > 0, "float32") gate_R = tf.cast(grad > 0, "float32") return gate_f * gate_R * grad Then, I obtained grads by: with g

cannot reshape array of size 1665179 into shape (512,512,3,3)

断了今生、忘了曾经 提交于 2021-02-10 05:33:24
问题 The script used to do detection. Weight file was yolov4 coco pre-trained model and that can be found over here.(https://drive.google.com/file/d/1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT/view) import time from absl import app, flags, logging from absl.flags import FLAGS import core.utils as utils from core.yolov4 import YOLOv4, YOLOv3, YOLOv3_tiny, decode from PIL import Image from core.config import cfg import cv2 import numpy as np import tensorflow as tf flags.DEFINE_string('framework', 'tf', '(tf,

stable-baseline with tensorflow issue

烂漫一生 提交于 2021-02-10 05:32:29
问题 It says: Stable-Baselines supports Tensorflow versions from 1.8.0 to 1.15.0, and does not work on Tensorflow versions 2.0.0 and above. So I tried to install "sudo pip3 install tensorflow==1.15.0" But I get the message: ERROR: Could not find a version that satisfies the requirement tensorflow==1.15.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0) ERROR: No matching distribution found for tensorflow==1.15.0 I'm using: Ubuntu 20.04 LTS Python 3.8.2 pip 20.1.1 from .../python3.8

extracting numpy value from tensorflow object during transformation

旧时模样 提交于 2021-02-10 05:13:14
问题 i am trying to get word embeddings using tensorflow, and i have created adjacent work lists using my corpus. Number of unique words in my vocab are 8000 and number of adjacent word lists are around 1.6 million Word Lists sample photo Since the data is very large i am trying to write the word lists in batches to TFRecords file. def save_tfrecords_wordlist(toprocess_word_lists, path ): writer = tf.io.TFRecordWriter(path) for word_list in toprocess_word_lists: features=tf.train.Features( feature

extracting numpy value from tensorflow object during transformation

醉酒当歌 提交于 2021-02-10 05:07:38
问题 i am trying to get word embeddings using tensorflow, and i have created adjacent work lists using my corpus. Number of unique words in my vocab are 8000 and number of adjacent word lists are around 1.6 million Word Lists sample photo Since the data is very large i am trying to write the word lists in batches to TFRecords file. def save_tfrecords_wordlist(toprocess_word_lists, path ): writer = tf.io.TFRecordWriter(path) for word_list in toprocess_word_lists: features=tf.train.Features( feature

Add a index selected numpy array to another numpy array with overlapping indices

寵の児 提交于 2021-02-10 03:44:05
问题 I have two numpy arrays image and warped_image and indices arrays ix,iy . I need to add image to warped_image such that image[i,j] is added to warped_image[iy[i,j],ix[i,j]] . The below code works if the pairs (iy[i,j], ix[i,j]) are unique for all i,j . But when they are not unique i.e. when 2 elements from image need to be added to the same element in warped_image , only one of them gets added. How can I add both elements from image to the same element in warped_image ? Note that, I don't

Add a index selected numpy array to another numpy array with overlapping indices

耗尽温柔 提交于 2021-02-10 03:42:43
问题 I have two numpy arrays image and warped_image and indices arrays ix,iy . I need to add image to warped_image such that image[i,j] is added to warped_image[iy[i,j],ix[i,j]] . The below code works if the pairs (iy[i,j], ix[i,j]) are unique for all i,j . But when they are not unique i.e. when 2 elements from image need to be added to the same element in warped_image , only one of them gets added. How can I add both elements from image to the same element in warped_image ? Note that, I don't

How to use model input in loss function?

梦想的初衷 提交于 2021-02-10 03:28:07
问题 I am trying to use a custom loss-function which depends on some arguments that the model does not have. The model has two inputs ( mel_specs and pred_inp ) and expects a labels tensor for training: def to_keras_example(example): # Preparing inputs return (mel_specs, pred_inp), labels # Is a tf.train.Dataset for model.fit(train_data, ...) train_data = load_dataset(fp, 'train).map(to_keras_example).repeat() In my loss function I need to calculate the lengths of mel_specs and pred_inp . This

How to use model input in loss function?

北城余情 提交于 2021-02-10 03:23:55
问题 I am trying to use a custom loss-function which depends on some arguments that the model does not have. The model has two inputs ( mel_specs and pred_inp ) and expects a labels tensor for training: def to_keras_example(example): # Preparing inputs return (mel_specs, pred_inp), labels # Is a tf.train.Dataset for model.fit(train_data, ...) train_data = load_dataset(fp, 'train).map(to_keras_example).repeat() In my loss function I need to calculate the lengths of mel_specs and pred_inp . This

How to use model input in loss function?

心已入冬 提交于 2021-02-10 03:23:25
问题 I am trying to use a custom loss-function which depends on some arguments that the model does not have. The model has two inputs ( mel_specs and pred_inp ) and expects a labels tensor for training: def to_keras_example(example): # Preparing inputs return (mel_specs, pred_inp), labels # Is a tf.train.Dataset for model.fit(train_data, ...) train_data = load_dataset(fp, 'train).map(to_keras_example).repeat() In my loss function I need to calculate the lengths of mel_specs and pred_inp . This