# Questions tagged [tensorflow]

9922 questions

0

votes

0

answer

3

Views

### Keras NASNet training

I intend to:
Train NASNet from scratch on a dataset
Re-train only the last layer of NASNet (transfer learning)
and compare their relative performance. From the documentation i see:
keras.applications.nasnet.NASNetLarge(input_shape=None, include_top=True, weights='imagenet', input_tensor=None, poolin...

3

votes

0

answer

25

Views

### Gather subtensor of padded tensor of variable-sized data in Tensorflow

I have some variable-length sequencial data of fixed tensor dimension.
Consider a list of tensors s_1, ..., s_b of a list of some fixed dimensional matrices [l_1,m,n], ..., [l_b,m,n].
For example
s_1 = [ [[1,2],[3,4]], [[5,6],[7,8]] ]
s_2 = [ [[9,10],[11,12]], [[13,14],[15,16]], [[17,18],[19,20]] ]...

1

votes

0

answer

4

Views

### tcmalloc: large alloc … killed in Google Colab

I was trying to setup MuseGAN in Google Colab. I already downloaded the data and I am now processing the data by storing it into the shared memory using the SharedArray package, by running the script ./scripts/process_data.sh. I encountered this error
> Loading data from '/content/musegan/scripts/.....

0

votes

1

answer

50

Views

### Send SIGTERM to the running task, dask distributed

When I submit a small Tensorflow training as a single task, it launches additional threads. When I press Ctrl+C and raise KeyboardInterrupt my task is closed but underlying threads are not cleaned up and training continues.
Initially, I was thinking that this is a problem of Tensorflow (not cleaning...

0

votes

0

answer

7

Views

### Include currently predicted model in custom loss function

It is something similar to this which says that it is impossible (or very hard) to define loss function which depends on the model under training. I wonder if such loss function can be defined in TensorFlow or pyTorch.
A simplified example problem is the following:
Basically, the model take two inpu...

0

votes

0

answer

17

Views

### Neural Network based Aimbot [on hold]

i´m new at this topic (neural networks).
I only wanna code just for testing it, an Aimbot in CSGO for singleplayer.
So i found a good video on youtube. But if i do this, it´s laggy in games like battlefield.
Can you say me, what´s the problem in my code?
Sry for mistakes.
[Pastebin Link][1]
I h...

0

votes

0

answer

8

Views

### keras incorrectly logs losses

I'm training WGAN with keras, critic model is compiled in the following way:
self.critic_combined.compile(optimizer=k.optimizers.Adam(0.0001, beta_1=0.5, beta_2=0.9),
loss=[self.wasserstein_loss,
self.wasserstein_loss,
self.gradient_penalty_loss],
loss_weights=[1, 1, 10])
When i run it with train o...

0

votes

0

answer

5

Views

### how to prepare `bias` vector in tensor2tensor?

I am having problem understanding how bias works in tensor2tensor, specially in multihead_attention or dot_product_attention. I want to use it as a library for my problem.
Lets say I have an input tensor, T with dimension, (batch, max_input_length, hidden_unit) for a batch of sentences S. And I also...

1

votes

1

answer

56

Views

### How to get boolean mask for padding

Using tf.extract_image_patches with padding 'SAME' will result in some patches containing padding (that is fine).
Is there an easy way to get a TensorFlow boolean mask which masks all patches containing padding? Or will I need to reimplement the padding process?

0

votes

0

answer

5

Views

### Tensorflow Parameter Server Hangs when doing distributed training with Estimator

System information
- TensorFlow version:1.5, 1.8, 1.12 all the same results
- MacOS 10.14.3
Is parameter server expected to be killed after the training is done when using tf.estimator.Estimator for distributed training ? or it is a expected behavior that ps hangs forever ?
I am trying simple mnist...

1

votes

0

answer

7

Views

### How to multiply each 2D element of a tensor with dynamic dimension by a static 2D mask?

I have an input Tensor of size (?, 64, 64) and a static Tensor mask of size (64, 64).
I want the output tensor of this model to be of shape (?, 64, 64) where the i_th element of the output is an element by element multiplication of the i_th element of the input and the mask.
I've tried using the Mul...

9

votes

2

answer

162

Views

### Training a tf.keras model with a basic low-level TensorFlow training loop doesn't work

Note: All code for a self-contained example to reproduce my problem can be found below.
I have a tf.keras.models.Model instance and need to train it with a training loop written in the low-level TensorFlow API.
The problem:
Training the exact same tf.keras model once with a basic, standard low-level...

0

votes

0

answer

2

Views

### Should the random noise given to a GAN kept constant?

I am working on a Generative Adversarial Network ( GAN ). At every step, in the training, I call a method generate_noise which returns a tensor of some random noise.
# Generates noise of normal distribution
def generate_noise( shape : tuple ):
noise = tf.random_normal( shape )
return noise
When I ca...

1

votes

1

answer

122

Views

### wrong output size after conv2d function

the image size is [m,32,32,3] (m = no. of training examples)
the filter size is [3,3,3,10]
stride = 1
padding = None
if I convolve this using tensorflow.nn.conv2d then the output shape should be this, according to the formula
out ={ ( 32 - 3 + 2*(0) ) / 1 }+ 1 = 30
so the output size should be [m,...

0

votes

0

answer

14

Views

### How to stop Keras from ordering layer output?

I am trying to create a Conv2D layer in Keras (with tensorflow backend) and I've noticed that its output is ordeed in ascending manner.
For example, consider a simple input such as this:
_input = np.arange(2 * 2).reshape(2, 2)
which results in:
[[0 1]
[2 3]]
If we pass the _input variable to a convo...

1

votes

1

answer

549

Views

### quesion about the axis of tf.stack()

I read the doc of tf.stack() on tensorflow stack . There is an example on the page:
>>> x = tf.constant([1, 4])
>>> y = tf.constant([2, 5])
>>> z = tf.constant([3, 6])
>>> sess=tf.Session()
>>> sess.run(tf.stack([x, y, z]))
array([[1, 4],
[2, 5],
[3, 6]], dtype=int32)
>>> sess.run(tf.stack([x, y, z]...

1

votes

2

answer

126

Views

### Is stateful processing possible with the apache beam python sdk?

I have been following the Timely (and Stateful) Processing with Apache Beam article and though comprehensive and well written it does not specify how to achieve the same with python. More specifically
it states:
State and timers are not yet supported in Beam's Python SDK.
It does not state the reas...

1

votes

3

answer

1.2k

Views

### Cannot set attribute. Group with name “keras_version” exists

I have updated the example program in the keras
cifar10_resnet to work on the cifar 100 instead of cifar 10 data set. I am able to run the code only for the first epoch. When i try to save the model the programs breaks with the below error -
'KeyError: 'Cannot set attribute. Group with name "ke...

1

votes

2

answer

513

Views

### How to convert keras(h5) file to a tflite file?

I got an keras(h5) file. I need to convert it to tflite??
I researched, First i need to go via h5 -> pb -> tflite
(because h5 - tflite sometimes results in some issue)

1

votes

1

answer

83

Views

### Tensorflow access denied in config_util.py while training

I have a problem with training a model in tensorflow. I am working on Windows 10. When I run the command:
python ./object_detection/model_main.py --pipeline_config_path=C:/Tensorflow/object-detection/ssd_mobilenet_v1_coco_2018_01_28 --model_dir=C:/Tensorflow/object-detection/output-model --num_train...

0

votes

0

answer

4

Views

### Vanishing Gradient and Diverging problems in machine learning using tensorflow and python3

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
#feature [height, weight, foot size]
#label [0 = woman, 1 = man]
#Goal : Predict man or woman for x_test
x_test = np.array([[162,50,240],#woman
[156,49,225],
[163,53,255],
[167,65,260],
[175,68,270],
[180,70,275]
], dty...

1

votes

2

answer

30

Views

### concatenate images from a matrix of images

I have 4 images, each have width and height of 8. They belong inside a vector with shape [4,8,8]. I reshape the vector of images to become a matrix of images with shape [2,2,8,8].
How can I concatenate the images from inside the matrix to produce a single image so that the shape becomes [16,16]? I w...

2

votes

1

answer

31

Views

### Invalid free with Eigen ArrayXf

I've got a class that has an Eigen::ArrayXf member:
class Foo {
Foo(int size) : will_cause_problems(size) {}
Eigen::ArrayXf will_cause_problems;
};
When that class goes out of scope the ArrayXf is also freed but it calls free with the wrong address and I get double free or corruption errors (or in V...

0

votes

0

answer

8

Views

### Encountering ImportError when trying to import tensorflow

I've been trying to run a file that I programmed on another computer that had tensorflow installed. However, I keep getting the following error:
Traceback (most recent call last):
File "G:/BACKUP/AI/Neural network.py", line 1, in
import tensorflow as tf
File "C:\Users\adity\AppData\Local\Programs\P...

0

votes

0

answer

2

Views

### How to convert output from interpreter.run in java

I try to use TensorflowLite with one of the models from https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md converted to tflite file to detect objects from camera stream in my android app (java). I execute
interpreter.run(input, output);
where inpu...

-2

votes

0

answer

12

Views

### Keras: CNN + LSTM for video recognition

I am trying to implement the Model shown in the above picture that basically consists of time-distributed CNNs followed by a sequence of LSTMs using Keras with TF. I have divided two types of class, and extract 10 frames from each video captured.
I have extracted 10 frames for each video and stored...

0

votes

1

answer

22

Views

### Train and validation score is high but very Poor Test Accuracy

I am working on multi-label image classification, i am using inception net as my base architecture.
after the complete training i am getting, training accuracy > 90% and validation accuracy > 85% but i am getting 17% accuracy on test data.
Model training -->
model = Model(pre_trained_model.input, x)...

7

votes

0

answer

123

Views

### Tensorflow-Deeplearning - Correlation between input and output

I'm experimenting with tensorflow for speech recognition.
I have inputs as waveforms and words as output.
The waveform would look like this
[0,0,0,-2,3,-4,-1,7,0,0,0...0,0,0,20,-11,4,0,0,1,...]
The words would be an array of numbers while each number represents a word:
[12,4,2,3]
After training I a...

5

votes

1

answer

62

Views

### Executing tensorflow python3 on remote server, subprocess can't interpret all of tensorflows input args. ImportError: No module named 'scripts'

I'm trying to execute tensorflow image identification on a remote server from my local host. My local machine has a script that runs this subprocess ssh command to execute the script on the remote server.
stdoutdata = subprocess.getoutput('sshpass -p \'mypassword\' ssh [email protected] "python3 ../va...

1

votes

1

answer

6.2k

Views

### google.protobuf.message.DecodeError: Error parsing message

I am doing the tutorial on https://www.tensorflow.org/versions/master/tutorials/image_recognition/index.html
and working on the Python API section, I launched
python classify_image.py
Here I am getting the error message out like so:
A protocol message was rejected because it was too big (more than 6...

0

votes

0

answer

2

Views

### Image classification: making a suitable xs input for model.fit(xs, ys, {options…})

(I am just starting tensorflow.js on node)
I have been searching the web up and down for an answer.
The confusion
I have image data from image1 = tf.fromPixels(img) and I tried inputting it along with other image data to xs = tf.tensor([image1, image2]). The confusion is no matter how I input a bunc...

0

votes

0

answer

8

Views

### Can I choose to manually update weights in my neural network to allow an essentially infinite batch size?

I am feeding large images into my CNN, and for some reason, converting the images to grayscale or making my network much smaller has no impact whatsoever on my maximum batch size. If I do anything more than 4, I run out of memory on my 16GB cpu. I am loading in each batch at a time, but I still run...

0

votes

1

answer

13

Views

### How to find the max index for each row in a tensor object?

So I'm creating a pytorch model and for the forward pass, I'm applying my forward pass method to get the scores tensor which contains the prediction scores for each class. The shape of this tensor is [100, 10]. Now, I want to get the accuracy by comparing it to y which contains the actual scores. Th...

1

votes

1

answer

474

Views

### no module named 'Pil' while using tensorflow

I am totally new to Machine learning. I was using Tensorflow for machine learning. While, i was following code lab for this. And i was compressing my model and testing it using following script
python -m scripts.evaluate tf_files/optimized_graph.pb
i got this exception no module name 'Pil'
below i...

1

votes

2

answer

1.2k

Views

### TensorFlow: Implementing Single layer perceptron / Multi layer perceptron using own data set

I am new to TensorFlow. I looked for examples on implementation of multi layer perceptron using tensorflow, but i am getting examples only on MNIST image data sets, apart from MNIST can i able to build the Neural Network model using same optimization and cost functions and train the data which is...

2

votes

0

answer

118

Views

### How to extract forecasting errors from all training sets into a single data frame in R?

By forecasting errors, I mean the differences between predicted and actual values.
I am doing a time series analysis using a deep learning model called the long-short term memory (LSTM) based on this great article. The author distributed the data set into 11 samples to train the model and then make...

0

votes

0

answer

6

Views

### Optimizing customized loss function with some parameters in sklearn

I have dataset with features x and labels y. I also have some prior knowledge about the functional form of the function with some unknown parameters. I want to infer the parameters (based on OLS solution). I googled a lot but didn't find a solution in sklearn library?
Actually, I found another solut...

1

votes

1

answer

499

Views

### get intermediate output from Keras/Tensorflow during prediction

Let's say I load inception, and I need to extract the final descriptor just before classification.
So given a simple code like this:
cnn = InceptionV3(weights='imagenet',
include_top='False',
pooling='avg')
cnn.predict(x, batch_size=32, verbose=0)
How can I extract during prediction the last layer?

1

votes

1

answer

614

Views

### Tensorflow Dataset API restore Iterator after completing one epoch

I have 190 features and labels,My batch size is 20 but after 9 iterations tf.reshape is returning exception Input to reshape is a tensor with 21 values,but the requested shape has 60 and i know it is due to Iterator.get_next().How do i restore my Iterator so that it will again start serving batches...

1

votes

2

answer

1.8k

Views

### No result of tf.Print in keras's model.fit

I wrote that loss (for testing custom loss in keras):
def loss(y_true, y_pred):
loss = -tf.reduce_sum(y_true * tf.log(y_pred))
loss = tf.Print(loss, [loss], 'loss = ')
return loss
and then:
model.compile(loss=loss,
optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy'])
model.fit(x_train, y_tr...