tensorflow

Keras' fit_generator() for binary classification predictions always 50%

落花浮王杯 提交于 2021-02-10 17:30:00
问题 I have set up a model to train on classifying whether an image is a certain video game or not. I pre-scaled my images into 250x250 pixels and have them separated into two folders (the two binary classes) labelled 0 and 1 . The amount of both classes are within ~100 of each other and I have around 3500 images in total. Here are photos of the training process, the model set up and some predictions: https://imgur.com/a/CN1b6LV train_datagen = ImageDataGenerator( rescale=1. / 255, shear_range=0,

Keras' fit_generator() for binary classification predictions always 50%

梦想的初衷 提交于 2021-02-10 17:29:29
问题 I have set up a model to train on classifying whether an image is a certain video game or not. I pre-scaled my images into 250x250 pixels and have them separated into two folders (the two binary classes) labelled 0 and 1 . The amount of both classes are within ~100 of each other and I have around 3500 images in total. Here are photos of the training process, the model set up and some predictions: https://imgur.com/a/CN1b6LV train_datagen = ImageDataGenerator( rescale=1. / 255, shear_range=0,

Tensorflow Lite tflite模型的生成与导入

妖精的绣舞 提交于 2021-02-10 16:59:25
假如想要在ARM板上用 tensorflow lite ,那么意味着必须要把PC上的模型生成 tflite 文件,然后在ARM上导入这个 tflite 文件,通过解析这个文件来进行计算。 根据前面所说, tensorflow 的所有计算都会在内部生成一个图,包括变量的初始化,输入定义等,那么即便不是经过训练的神经网络模型,只是简单的三角函数计算,也可以生成一个 tflite 模型用于在 tensorflow lite 上导入。所以,这里我就只做了简单的 sin() 计算来跑一编这个流程。 生成 tflite 模型 这部分主要是调用 TFLiteConverter 函数,直接生成 tflite 文件,不再通过 pb 文件转化。 先上代码: import numpy as np import time import math import tensorflow as tf SIZE = 1000 X = np.random.rand(SIZE, 1 ) X = X*(math.pi/2.0 ) start = time.time() x1 = tf.placeholder(tf.float32, [SIZE, 1], name= ' x1-input ' ) x2 = tf.placeholder(tf.float32, [SIZE, 1], name= ' x2-input ' )

ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine'

半世苍凉 提交于 2021-02-10 16:21:32
问题 I'm getting this error while loading the ternsoflow addons library import tensorflow_addons as tfa ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine' 回答1: This error is because you have incompatibility issues between your TensorFlow , Python and tensorflow-addons . Uninstall the tensorflow-addons and install the version based on the table below. Refer the Github repo for more information. 来源: https://stackoverflow.com/questions/65464463/importerror-cannot

How can I cleanly normalize data and then “unnormalize” it later?

匆匆过客 提交于 2021-02-10 16:21:07
问题 I am using Anaconda with a Tensorflow neural network. Most of my data is stored with pandas . I am attempting to predict cryptocurrency markets. I am aware that this lots of people are probably doing this and it is most likely not going to be very effective, I'm mostly doing it to familiarize myself with Tensorflow and Anaconda tools. I am fairly new to this, so if I am doing something wrong or suboptimally please let me know. Here is how I aquire and handle the data: Download datasets from

How can I cleanly normalize data and then “unnormalize” it later?

风流意气都作罢 提交于 2021-02-10 16:19:52
问题 I am using Anaconda with a Tensorflow neural network. Most of my data is stored with pandas . I am attempting to predict cryptocurrency markets. I am aware that this lots of people are probably doing this and it is most likely not going to be very effective, I'm mostly doing it to familiarize myself with Tensorflow and Anaconda tools. I am fairly new to this, so if I am doing something wrong or suboptimally please let me know. Here is how I aquire and handle the data: Download datasets from

Using tensorflow in C++ on Windows

十年热恋 提交于 2021-02-10 16:18:36
问题 I know there are ways of using Tensorflow in C++ they even have a documentation for it but I can seem to be able to get the library for it. I've checked the build from source instructions but it seems to builds a pip package rather than a library I can link to my project. I also found a tutorial but when I tried it out I ran out of memory and my computer crashed. My question is, how can I actually get the C++ library to work on my project? I do have these requirements, I have to work on

Tensorflow keras timeseries prediction with X and y having different shapes

不羁的心 提交于 2021-02-10 15:44:10
问题 I am trying to do time series prediction with tensorflow and keras with X and y having different dimensions: X.shape = (5000, 12) y.shape = (5000, 3, 12) When I do the following n_input = 7 generator = TimeseriesGenerator(X, y, length=n_input, batch_size=1) for i in range(5): x_, y_ = generator[i] print(x_.shape) print(y_.shape) I get as desired the output (1, 7, 12) (1, 3, 12) (1, 7, 12) (1, 3, 12) ... This is because my data is meteorological, I have 5000 days, for training in the array X I

Tensorflow keras timeseries prediction with X and y having different shapes

半世苍凉 提交于 2021-02-10 15:43:05
问题 I am trying to do time series prediction with tensorflow and keras with X and y having different dimensions: X.shape = (5000, 12) y.shape = (5000, 3, 12) When I do the following n_input = 7 generator = TimeseriesGenerator(X, y, length=n_input, batch_size=1) for i in range(5): x_, y_ = generator[i] print(x_.shape) print(y_.shape) I get as desired the output (1, 7, 12) (1, 3, 12) (1, 7, 12) (1, 3, 12) ... This is because my data is meteorological, I have 5000 days, for training in the array X I

Feeding values to a Variable using feed_dict in TensorFlow

二次信任 提交于 2021-02-10 15:42:58
问题 I'm through https://www.tensorflow.org/get_started/mnist/pros . Reading "Note that you can replace any tensor in your computation graph using feed_dict -- it's not restricted to just placeholders," I tried to give values to a Variable using feed_dict as follows: print(accuracy.eval(feed_dict={x: mnist.test.images, y_: mnist.test.labels, W[:, :]: np.zeros((784, 10))})) However, it gave the original accuracy 0.9149 (I expected around 0.1). Can I give constant values to Variables after