keras

Converting Array of Lists to Keras Input

谁说胖子不能爱 提交于 2021-02-08 01:49:30
问题 Given an array of the form array([list([21603, 125, 737, 579, 2065, 10399, 1175, 0, 0, 0]), ... list([1896, 3917, 498, 296, 1452, 523, 754, 450, 3795, 341])], dtype=object) How do you prepare it to be consumed by a Keras model in TensorFlow 2.0 RC0? In its current form it throws the error ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list). and I can't seem to get it in the form I'm familiar with, array([[21603, 125, 737, 579, 2065, 10399, 1175, 0, 0, 0], ..

How to make predictions using a model that requires an input shape with more than two dimensions using MLflow?

雨燕双飞 提交于 2021-02-07 23:00:16
问题 I'm trying to implement a tensorflow (keras) based model into mlflow while learning how it works and if it suite our needs. I'm trying to implement the Fashion MNIST example from tensorflow website Here the link I was able to train and to log the model successfully into mlflow using this code: import mlflow import mlflow.tensorflow import mlflow.keras # TensorFlow and tf.keras import tensorflow as tf from tensorflow import keras # Helper libraries import numpy as np import matplotlib.pyplot

ImportError: cannot import name 'keras'

允我心安 提交于 2021-02-07 18:47:25
问题 When running this in Jupyter notebooks (python): import tensorflow as tf from tensorflow import keras I get this error: ImportError: cannot import name 'keras' I've tried other commands in place of the second one, such as (but not limited to) from tensorflow.keras import layers But it always returns some error. I'm using the online version of Jupyter, and running print(tf.VERSION) returns 1.1.0. I'm not sure if the problem is just that I have the wrong version, or if it's something else. How

How to experiment with custom 2d-convolution kernels in Keras?

微笑、不失礼 提交于 2021-02-07 14:33:25
问题 In a default Conv2D layer with kernel_size=3 the weights of a slice of one of the filters could be named like this: A B C D E F G H I With kernel_size=5 like this: A B C D E F G H I J K L M N O P Q R S T U V W X Y Now I'd like to build (and train/test) a model based on conv layers with kernels like that: A A B C C A A B C C D D E F F G G H I I G G H I I How could the implementation of such a custom layer look like? 回答1: Maybe like this? class CustomConv2D(Layer): def __init__(self, filters, *

How does shuffle = 'batch' argument of the .fit() layer work in the background?

白昼怎懂夜的黑 提交于 2021-02-07 14:25:30
问题 When I train the model using the .fit() layer there is the argument shuffle preset to True. Let's say that my dataset has 100 samples and that the batch size is 10. When I set shuffle = True then keras first randomly selects randomly the samples (now the 100 samples have a different order) and on the new order it will start creating the batches: batch 1: 1-10, batch 2: 11-20 etc. If I set shuffle = 'batch' how is it supposed to work in the background? Intuitively and using the previous

Is fit_generator in Keras supposed to reset the generator after each epoch?

╄→гoц情女王★ 提交于 2021-02-07 14:22:22
问题 I am trying to use fit_generator with a custom generator to read in data that's too big for memory. There are 1.25 million rows I want to train on, so I have the generator yield 50,000 rows at a time. fit_generator has 25 steps_per_epoch , which I thought would bring in those 1.25MM per epoch. I added a print statement so that I could see how much offset the process was doing, and I found that it exceeded the max when it got a few steps into epoch 2. There are a total of 1.75 million records

Is fit_generator in Keras supposed to reset the generator after each epoch?

人走茶凉 提交于 2021-02-07 14:22:12
问题 I am trying to use fit_generator with a custom generator to read in data that's too big for memory. There are 1.25 million rows I want to train on, so I have the generator yield 50,000 rows at a time. fit_generator has 25 steps_per_epoch , which I thought would bring in those 1.25MM per epoch. I added a print statement so that I could see how much offset the process was doing, and I found that it exceeded the max when it got a few steps into epoch 2. There are a total of 1.75 million records

Keras Neural Network Error: Setting an Array Element with a Sequence

家住魔仙堡 提交于 2021-02-07 13:58:22
问题 I'm loading dummy data into a neural network, but I'm receiving an error I can't seem to debug: Here is my data, visualized: df: Label Mar 0 | [[.332, .326], [.058, .138]] 0 | [[.234, .246], [.234, .395]] 1 | [[.084, .23], [.745, .923]], I'm trying to use the 'Mar' column to predict the 'Label' column (I know this data makes no sense, its just similar to my real data). Here is my neural network code: model = Sequential() model.add(Dense(3, input_dim=(1), activation='relu')) model.add(Dense(1,

Extract target from Tensorflow PrefetchDataset

回眸只為那壹抹淺笑 提交于 2021-02-07 12:59:41
问题 I am still learning tensorflow and keras, and I suspect this question has a very easy answer I'm just missing due to lack of familiarity. I have a PrefetchDataset object: > print(tf_test) $ <PrefetchDataset shapes: ((None, 99), (None,)), types: (tf.float32, tf.int64)> ...made up of features and a target. I can iterate over it using a for loop: > for example in tf_test: > print(example[0].numpy()) > print(example[1].numpy()) > exit() $ [[-0.31 -0.94 -1.12 ... 0.18 -0.27] [-0.22 -0.54 -0.14 ...

How to train keras model using Google Cloud TPU

血红的双手。 提交于 2021-02-07 12:11:44
问题 Theoretically, we are able to train Tensorflow backed Keras model on any platform that supports Tensorflow. However, I can't seem to find any info on how to do it in Google's documentation https://cloud.google.com/tpu/docs/. 回答1: We have an example in the TPU repository here: https://github.com/tensorflow/tpu/blob/master/models/experimental/cifar_keras/cifar_keras.py 来源: https://stackoverflow.com/questions/48771723/how-to-train-keras-model-using-google-cloud-tpu