All Questions
25
questions
11
votes
1
answer
25k
views
How to save a list of numpy arrays into a single file and load file back to original form [duplicate]
I am currently trying to save a list of numpy arrays into a single file, an example of such a list can be of the form below
import numpy as np
np_list = []
for i in range(10):
if i % 2 == 0:
...
5
votes
0
answers
1k
views
Understanding why EagerTensor.numpy() is slow
I'm trying to make predictions using a pre-trained custom image segmentation model on some image data but I'm having problems with the predictions being too slow.
After doing some profiling using ...
1
vote
1
answer
524
views
Equivalent of np.convolve in keras backend
I have following function
def pad_ones(arr):
return np.convolve(arr, [1, 1, 1], "same")
# for example:
# >>> pad_ones([0, 0, 0, 1, 0, 0])
# array([0, 0, 1, 1, 1, 0])
which I ...
1
vote
1
answer
79
views
Share operation result between Keras metrics
I have a (time-expensive) operation that multiple metrics have in common. What would be the best way to share the operation result between the metrics avoiding the overhead of recalculating it each ...
1
vote
1
answer
86
views
numpy array for sequential network: varying sequence length
I have a recurrent network (RNN) whose task is to learn to classify vectors (float32) in two classes. My model is really simple so far:
model = Sequential([
SimpleRNN(units=10, input_shape=(None, ...
1
vote
2
answers
3k
views
Keras model shape incompatible / ValueError: Shapes (None, 3) and (None, 3, 3) are incompatible
I'm trying to train my keras model but shapes are incompatible.
The error says
ValueError: Shapes (None, 3) and (None, 3, 3) are incompatible
My train set's shape is (2000, 3, 768) and lable's shape ...
1
vote
1
answer
880
views
Use Keras model on dataset of Numpy arrays?
I am working on a classification project and have a dataset consisting of 2d Numpy arrays (let us call them negative and positive).
I am familiar with Keras classification by simply using the image ...
1
vote
0
answers
15
views
Converting .xls data to Python data types to be used as an input of a Tensorflow Lite model
I've captured and saved accelerometer values to an xls worksheet. I want to use these as an input to a Tensorflow Lite model but I'm struggling to do the required data conversions.
A simplified ...
1
vote
1
answer
727
views
Keras Predict Single Example with keras.predict?
I am sure/hopeful that this is a very simple problem, but I haven't been able to find any answers.
I've made a sequential model in Keras with 366 inputs neurons and one output neuron. It seems to ...
1
vote
0
answers
8k
views
TypeError: Cannot convert value dtype to a TensorFlow DType
I am fairly new to tensorflow. I am loading a model from a .h5 file and trying to make a prediction using the model.
import tensorflow as tf
import pandas as pd
import numpy as np
file_path = '/path/...
0
votes
1
answer
2k
views
Input 0 incompatible with layer inception_v3 expected shape=(None, 299, 299, 3), found shape=(1, 229, 229, 3)
How to convert shape=(1, 299, 299, 3) to expected shape=(None, 299, 299, 3) to feed into trained inception v3 model.
NOTE: THE SAME QUESTION HAVE BEEN ASKED BEFORE BUT THE ANSWER ISN'T CLEAR ENOUGH.
...
0
votes
1
answer
32
views
How to predict (multi) labeled datapoints?
for example if I have 5 points and each point has dimension of 3 and has one of 10 possible labels from 0 to 9.
Points
XTrain:
[[0.20861965 0.47901568 0.92075312],
[0.96175914 0.70659989 0.82364516],...
0
votes
1
answer
330
views
ValueError: Unable to convert NumPy array to a Tensor (Unsupported object type float)
I'm having a real problem diagnosing an issue I have with Tensorflow. I get this ValueError and it's not intuitive at all. I've tried converting my floats to np.float32 as specified in other SO ...
0
votes
1
answer
23
views
ValueError: (205087,) but got (1,), using fit_generator on onehot vectors in keras
Alright so I am experimenting with keras as part of a project, and I get the following error that I just can't seem to resolve:
ValueError: Error when checking input: expected input_1 to have shape (...
0
votes
0
answers
42
views
Received ValueError: zero-size array to reduction operation maximum which has no identity while passing image to keras ocr
i expected the function to accept the image and read the text from it
here's my function
def read_image(self, image):
keras_pipeline = keras_ocr.pipeline.Pipeline()
img = ...
0
votes
1
answer
457
views
how to add 'None' column to nparray
I am trying to use the tf-explain library, but I am running into an error with the validation data for the GradCAM method.
I get the following error:
WARNING:tensorflow:Model was constructed with ...
0
votes
1
answer
1k
views
Input 0 of layer "model" is incompatible with the layer: expected shape=(None, 250, 3), found shape=(None, 3) in trained transformer model
I have a keras transformer model trained with tensorflow 2.7.0 and python 3.7 with input shape: (None, 250, 3) and a 2D array input with shape: (250, 3)(not an image)
When making a prediction with:
...
0
votes
0
answers
238
views
AttributeError: 'Tensor' object has no attribute 'numpy' while using tf.disable_v2_behavior()
I have tensor with shape (1, 3) and I'm using TensorFlow 2.4.1 but I have code that needs to run on the old version. So, I use
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
predicted_id ...
0
votes
1
answer
780
views
Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'>
I having trouble in here:
About the code: I create a model here. The first step is to initialize the model with Sequential(). After that, we flatten our data and add our additional 3 (or more) hidden ...
0
votes
1
answer
258
views
Tensorflow equivalent of numpy.random.normal
I am trying to add a Gaussian noise to output of each activation layer in a Keras pre-trained imagenet. I am inserting a custom layer after every activation layer. In this custom layer, I want to add ...
0
votes
1
answer
83
views
Tensorflow: Iterating over dataset takes 1-2 orders of magnitude longer than expected
Situation:
I have a dataset (<class 'tensorflow.python.data.ops.dataset_ops.MapDataset'> ) which is a result of some neural network output. In order to get my final prediction, I am currently ...
0
votes
2
answers
579
views
Using python lists and numpy arrays in tensorflow function(using @tf.function annotation)
I am building a LSTM model and am using tensorflow to build custom training loops, so that I can train the LSTM network with varying sequence lengths.
The training loops were running but was really ...
0
votes
1
answer
1k
views
TypeError: Tensors in list passed to 'values' of 'Pack' Op have types [string, float32] that don't all match. error from CSV tutorial
I got my own data for training, etc in TensorFlow. I got the Load CSV Data tutorial from TensorFlow on Colab, and I changed the config on some of the variables to match my data. When I ran the program,...
0
votes
1
answer
107
views
What does "?" in shape(?,12) means in keras?
While making a machine learning model in keras, I checked the shape of an element that gives the output (?,12).
I went through this
stackoverflow answer but did'nt understand what exactly (?,12) ...
0
votes
1
answer
14
views
My Model input_shape don't match my X's input_shape
I am developing an image denoiser with python for my scientific initiation scholarship, however, when I went to carry out the first test training, I came across some errors.
Basically I need to train ...