tensorflow2.0

Implementing an CLSTM but facing Dimension Error Problem

戏子无情 提交于 2020-02-06 07:24:06
问题 i am implementing a CLSTM based on This problem but facing error of dimensionality. Data set: I am currently working on one video, which has 4500 images of size (28,28) . The data set is in vectorized form so i get (4500,780) . I split the images using Timeseriessplit and reshape the images with x_train=x_train.reshape(-1, 28, 28, 1) x_test=x_test.reshape(-1, 28, 28, 1) My model is as follows model = models.Sequential() model.add(layers.ConvLSTM2D( filters=40, kernel_size=(3, 3), input_shape=

Implementing an CLSTM but facing Dimension Error Problem

不羁岁月 提交于 2020-02-06 07:24:05
问题 i am implementing a CLSTM based on This problem but facing error of dimensionality. Data set: I am currently working on one video, which has 4500 images of size (28,28) . The data set is in vectorized form so i get (4500,780) . I split the images using Timeseriessplit and reshape the images with x_train=x_train.reshape(-1, 28, 28, 1) x_test=x_test.reshape(-1, 28, 28, 1) My model is as follows model = models.Sequential() model.add(layers.ConvLSTM2D( filters=40, kernel_size=(3, 3), input_shape=

TensorFlow 2.0 Keras layers with custom tensors as variables

前提是你 提交于 2020-02-03 08:07:13
问题 In TF 1.x, it was possible to build layers with custom variables. Here's an example: import numpy as np import tensorflow as tf def make_custom_getter(custom_variables): def custom_getter(getter, name, **kwargs): if name in custom_variables: variable = custom_variables[name] else: variable = getter(name, **kwargs) return variable return custom_getter # Make a custom getter for the dense layer variables. # Note: custom variables can result from arbitrary computation; # for the sake of this

Keras custom metric sum is wrong

ⅰ亾dé卋堺 提交于 2020-01-30 05:30:07
问题 I tried implementing precision and recall as custom metrics as in https://datascience.stackexchange.com/questions/45165/how-to-get-accuracy-f1-precision-and-recall-for-a-keras-model/45166#45166?newreg=6190503b2be14e8aa2c0069d0a52749e, but for some reason the numbers were off (I do know about the average of batch problem, that's not what I'm talking about). So I tried implementing another metric: def p1(y_true, y_pred): return K.sum(y_true) Just to see what would happen... What I'd expect is

gradient calculation for bias term using GradientTape()

情到浓时终转凉″ 提交于 2020-01-25 07:50:06
问题 I want to calculate gradient tensors with respect to weight variables and bias term, separately. The gradient for weight variables is calculated correctly, But the gradient for bias is NOT computed well. Please, let me know what the problem is, or modify my code correctly. import numpy as np import tensorflow as tf X =tf.constant([[1.0,0.1,-1.0],[2.0,0.2,-2.0],[3.0,0.3,-3.0],[4.0,0.4,-4.0],[5.0,0.5,-5.0]]) b1 = tf.Variable(-0.5) Bb = tf.constant([ [1.0], [1.0], [1.0], [1.0], [1.0] ]) Bb = b1*

Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

妖精的绣舞 提交于 2020-01-25 06:39:42
问题 I just installed the latest version of Tensorflow via pip install tensorflow and whenever I run a program, I get the log message: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found Is this bad? How do I fix the error? 回答1: Tensorflow 2.1+ What's going on? With the new Tensorflow 2.1 release, the default tensorflow pip package contains both CPU and GPU versions of TF. In previous TF versions,

How to combine a pre-trained KerasLayer from TensorFlow (v. 2) Hub and tfrecords?

て烟熏妆下的殇ゞ 提交于 2020-01-25 03:09:52
问题 I have a tfrecord with 23 classes with 35 images in each class (805 in total). My current tfrecord read function is: def read_tfrecord(serialized_example): feature_description = { 'image': tf.io.FixedLenFeature((), tf.string), 'label': tf.io.FixedLenFeature((), tf.int64), 'height': tf.io.FixedLenFeature((), tf.int64), 'width': tf.io.FixedLenFeature((), tf.int64), 'depth': tf.io.FixedLenFeature((), tf.int64) } example = tf.io.parse_single_example(serialized_example, feature_description) image

How to setup tfserving with inception/mobilenet model for image classification?

China☆狼群 提交于 2020-01-24 20:22:21
问题 I'm unable to find the proper documentation to successfully serve the inception or mobilenet models and write a grpc client to connect to the server and perform image classification. Till now, I've successfully configured the tfserving image on CPU only. Unable to run it on my GPU. But, when I make a grpc client request, the request fails with the error. grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Expects arg[0] to be

In TensorFlow 2.0 with eager-execution, how to compute the gradients of a network output wrt a specific layer?

◇◆丶佛笑我妖孽 提交于 2020-01-23 10:49:06
问题 I have a network made with InceptionNet, and for an input sample bx , I want to compute the gradients of the model output w.r.t. the hidden layer. I have the following code: bx = tf.reshape(x_batch[0, :, :, :], (1, 299, 299, 3)) with tf.GradientTape() as gtape: #gtape.watch(x) preds = model(bx) print(preds.shape, end=' ') class_idx = np.argmax(preds[0]) print(class_idx, end=' ') class_output = model.output[:, class_idx] print(class_output, end=' ') last_conv_layer = model.get_layer('inception

CUDNN_STATUS_BAD_PARAM when trying to perform inference on a LSTM Seq2Seq with masked inputs

末鹿安然 提交于 2020-01-22 15:00:20
问题 I'm using keras layers on tensorflow 2.0 to build a simple LSTM-based Seq2Seq model for text generation . versions I'm using: Python 3.6.9, Tensorflow 2.0.0, CUDA 10.0, CUDNN 7.6.1, Nvidia driver version 410.78. I'm aware of the criteria needed by TF to delegate to CUDNNLstm when a GPU is present (I do have a GPU and my model/data fill all these criteria). Training goes smoothly (with a warning message, see the end of this post) and I can verify that CUDNNLstm is being used. However, when I