keras

Keras hyperparameter autotune shortening the path

爷,独闯天下 提交于 2021-02-08 11:12:49
问题 this is the code that I am running. It is a self hyperparameter tuned ANN. The path is to long and I don't know how to shorten it. def build_model(hp): model = keras.Sequential() for i in range(hp.Int('num_layers', 2, 20)): model.add(layers.Dense(units=hp.Int('units_' + str(i), min_value=32, max_value=512, step=32), activation='relu')) model.add(layers.Dense(1, activation='linear')) model.compile( optimizer=keras.optimizers.Adam( hp.Choice('learning_rate', [1e-2, 1e-3, 1e-4])), loss='mean

Could not import PIL.Image even if Pillow already installed?

冷暖自知 提交于 2021-02-08 11:12:01
问题 I'm going through chapter 5 of the book Deep Learning with R (https://livebook.manning.com/book/deep-learning-with-r/chapter-5/112). When running the code below, the following error appears: Error in py_iter_next(it, completed) : ImportError: Could not import PIL.Image. The use of load_img requires PIL. All answers with regard to this error message recommend using pip install pillow . When I run this in my Terminal, the following appears: Requirement already satisfied: pillow in /anaconda3

Could not import PIL.Image even if Pillow already installed?

旧巷老猫 提交于 2021-02-08 11:11:35
问题 I'm going through chapter 5 of the book Deep Learning with R (https://livebook.manning.com/book/deep-learning-with-r/chapter-5/112). When running the code below, the following error appears: Error in py_iter_next(it, completed) : ImportError: Could not import PIL.Image. The use of load_img requires PIL. All answers with regard to this error message recommend using pip install pillow . When I run this in my Terminal, the following appears: Requirement already satisfied: pillow in /anaconda3

Could not import PIL.Image even if Pillow already installed?

我与影子孤独终老i 提交于 2021-02-08 11:10:59
问题 I'm going through chapter 5 of the book Deep Learning with R (https://livebook.manning.com/book/deep-learning-with-r/chapter-5/112). When running the code below, the following error appears: Error in py_iter_next(it, completed) : ImportError: Could not import PIL.Image. The use of load_img requires PIL. All answers with regard to this error message recommend using pip install pillow . When I run this in my Terminal, the following appears: Requirement already satisfied: pillow in /anaconda3

Could not import PIL.Image even if Pillow already installed?

笑着哭i 提交于 2021-02-08 11:06:17
问题 I'm going through chapter 5 of the book Deep Learning with R (https://livebook.manning.com/book/deep-learning-with-r/chapter-5/112). When running the code below, the following error appears: Error in py_iter_next(it, completed) : ImportError: Could not import PIL.Image. The use of load_img requires PIL. All answers with regard to this error message recommend using pip install pillow . When I run this in my Terminal, the following appears: Requirement already satisfied: pillow in /anaconda3

Keras loss becomes nan only at epoch end

寵の児 提交于 2021-02-08 10:30:21
问题 I am observing some strange behavior from Keras. I am training a small model where the training loss becomes nan only at the end of the first epoch. So if I have 100 batches, and I terminate training at batch 99, then resume for another 99 it trains fine. Otherwise, once it reaches the end of an epoch it always returns nan. I am using a custom loss function: def corr(x, y): xc = x - K.mean(x) yc = y - K.mean(y) r_num = K.mean(xc*yc) r_den = K.std(x)*K.std(y) return r_num/r_den And I have

Can I use dictionary in keras customized model?

我们两清 提交于 2021-02-08 09:52:03
问题 I recently read a paper about UNet++,and I want to implement this structure with tensorflow-2.0 and keras customized model. As the structure is so complicated, I decided to manage the keras layers by a dictionary. Everything went well in training, but an error occurred while saving the model. Here is a minimum code to show the error: class DicModel(tf.keras.Model): def __init__(self): super(DicModel, self).__init__(name='SequenceEECNN') self.c = {} self.c[0] = tf.keras.Sequential([ tf.keras

Can I use dictionary in keras customized model?

允我心安 提交于 2021-02-08 09:51:41
问题 I recently read a paper about UNet++,and I want to implement this structure with tensorflow-2.0 and keras customized model. As the structure is so complicated, I decided to manage the keras layers by a dictionary. Everything went well in training, but an error occurred while saving the model. Here is a minimum code to show the error: class DicModel(tf.keras.Model): def __init__(self): super(DicModel, self).__init__(name='SequenceEECNN') self.c = {} self.c[0] = tf.keras.Sequential([ tf.keras

Understand Keras LSTM weights

纵饮孤独 提交于 2021-02-08 09:24:27
问题 I can understand how to multiply Dense layer weights in order to get predicted output, but how can I interpret matrices from LSTM model? Here are some toy examples (don't mind fitting, it's just about matrix multiplication) Dense example: from keras.models import Model from keras.layers import Input, Dense, LSTM import numpy as np np.random.seed(42) X = np.array([[1, 2], [3, 4]]) I = Input(X.shape[1:]) D = Dense(2)(I) linear_model = Model(inputs=[I], outputs=[D]) print('linear_model.predict:

Keras model: Input shape dimension error for RL agent

谁说胖子不能爱 提交于 2021-02-08 09:20:07
问题 My goal is to develop a DQN-agent that will choose its action based on a certain strategy/policy. I previously worked with OpenAi gym-environments, but now I wanted to create my own RL environment. At this stage, the agent shall either choose a random action or choose his action based on the predictions given by a deep neural network (defined in the class DQN ). So far, I have setup both the neural net model and my environment . The NN shall receive states as its input. These states represent