tensorflow

During creating VAE model throws exception “you should implement a `call` method.”

扶醉桌前 提交于 2021-01-29 17:42:57
问题 I want to create VAE(variational autoencoder). During model creating it throws exception. When subclassing the Model class, you should implement a call method. I am using Tensorflow 2.0 def vae(): models ={} def apply_bn_and_dropout(x): return l.Dropout(dropout_rate)(l.BatchNormalization()(x)) input_image = l.Input(batch_shape=(batch_size,28,28,1)) x = l.Flatten()(input_image) x = l.Dense(256,activation="relu")(x) x = apply_bn_and_dropout(x) x = l.Dense(128,activation="relu")(x) x = apply_bn

how to Split data in 3 folds (train,validation,test) using ImageDataGenerator when data is in different directories of each class

China☆狼群 提交于 2021-01-29 17:34:53
问题 How do I split my data into 3 folds using ImageDataGenerator of Keras? ImageDataGenerator only gives validation_split argument so if I use it, I wont be having my test set for later purpose. My data is in the form of >input_data_dir >class_1_dir > image_1.png > image_2.png > class_2_dir > class_3_dir 回答1: As you rightly mentioned, splitting the Data into 3 Folds is not possible in one line of code using Keras ImageDataGenerator . Work around would be to store the Images corresponding to Test

problem with setting up tensorflow on windows

隐身守侯 提交于 2021-01-29 17:28:21
问题 I installed latest version of tensorflow that is 2.3 and when i try to import tensorflow i get below error runfile('C:/Users/Sriram/untitled1.py', wdir='C:/Users/Sriram') Traceback (most recent call last): File "<ipython-input-7-ae532bb97ae9>", line 1, in <module> runfile('C:/Users/Sriram/untitled1.py', wdir='C:/Users/Sriram') File "C:\Users\Sriram\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 435, in runfile __umr__.run() File "C:\Users\Sriram\anaconda3\lib

Keras predict_classes method returns “list index out of range” error

∥☆過路亽.° 提交于 2021-01-29 17:11:06
问题 I am new to CNN and machine learning in general and have been trying to follow Image Classification tutorial of TensorFlow. Now, the Google Colab can be found here. I've followed the this official tutorial of TensorFlow. And I've changed it slightly so it saves the model as h5 instead of tf format so I can use the Keras' model.predict_classes . Now, I have the model trained and the model reloaded from the saved model alright. But I'm repeatedly getting list index out of range error whenever I

Why does a TF server needs to know about all other tasks/workers in the cluster?

此生再无相见时 提交于 2021-01-29 16:50:41
问题 When starting a TensorFlow server ( tf.distribute.Server ), you must pass a ClusterSpec which specifies all tasks/workers in the cluster. Why? What does it use that information for? Is this just that device names (for tf.device ) can uniquely identify on what worker they run in the cluster? E.g. for with tf.device("/job:ps/task:0") or with tf.device("/job:worker/task:7") ? 来源: https://stackoverflow.com/questions/62004631/why-does-a-tf-server-needs-to-know-about-all-other-tasks-workers-in-the

Using Tensorflow / Keras: Image manipulation inside tf.py_function

為{幸葍}努か 提交于 2021-01-29 16:43:37
问题 I'm using Tensorflow 2.0 / Keras to generate building footprints for a procedural city. I would like to feed in a source image representing a city 'block', and have the network return the predicted building foundations. Input / Output I've had some success using a pix2pix-like GAN architecture, but the output would ideally be a vector image rather than a bitmap. I've therefore been trying to implement a different model, where the input image is convolved down to a 32x32 tensor, converted to a

Keras sequential network: Attempt to convert a value (75) with an unsupported type (<class 'numpy.int32'>) to a Tensor

那年仲夏 提交于 2021-01-29 16:33:58
问题 I am attempting to predict the ideal move in a game using a keras sequential network. The network is fairly simple with (what I think to be) an input shape of (3216,). The code for defining the network is attached bellow. self.model = keras.Sequential() self.model.add(Dense(2000, activation='relu', input_dim=(2 * 7 + 2 + Cfg.tiles_x * Cfg.tiles_y))) self.model.add(Dense(1000, activation='relu')) self.model.add(Dense(100, activation='relu')) self.model.add(Dense(9)) self.model.compile(loss

how to train model with batches

喜你入骨 提交于 2021-01-29 16:19:59
问题 I trying yolo model in python. To process the data and annotation I'm taking the data in batches. batchsize = 50 #boxList= [] #boxArr = np.empty(shape = (0,26,5)) for i in range(0, len(box_list), batchsize): boxList = box_list[i:i+batchsize] imagesList = image_list[i:i+batchsize] #to convert the annotation from VOC format convertedBox = np.array([np.array(get_boxes_for_id(box_l)) for box_l in boxList]) #pre-process on image and annotaion image_data, boxes = process_input_data(imagesList,max

Partitioning large dictionary (400k+) for finding words in words in Python 3

依然范特西╮ 提交于 2021-01-29 16:19:38
问题 in my neural network, I want to normalize words of a text. It means words get converted to infinitives and gender independent. Example: "Unternehmensgruppenführer" (german) gets 3 words: unternehmen gruppe fahren. This requires a lot of "startsWith" processing. I built a table that gives me word=>infinitive and loads it into a sorted(!) dictionary of length 400k. However, the processing of that dictionary by finding words in words got very slow. I optimized that with an implementation of

How to integrate Tensorflow (Keras) model into Windows application for fast inference (pref C++ real-time)

陌路散爱 提交于 2021-01-29 16:15:55
问题 Suppose I have an existing Windows application (hello1.exe). Suppose I also have a tf.Keras neural net model trained and classifying test data. How do I take the latter "out of the lab" and deploy it in the "real world" by combining the two components something like this: > hello2.exe cat.jpg Hello World. BTW: the file 'cat.jpg' contains a cat That is, hello2.exe extends my existing hello1.exe by using the trained model to infer the contents of the input file. I don't mind if the input data