当我试图在木星笔记本上导入keras时,我会收到以下错误消息: ModuleNotFoundError:没有名为'tensorflow‘的模块。
我需要使用keras为一个项目构建一个LSTM模型,并且我是python的初学者,所以我不知道如何避免这个错误。我试图将tenserflow和keras安装到anaconda上的环境中,但我也收到了同样的错误。作为参考,我正在使用Mac。
我的代码:
#Import libraries used
import math
import pandas as pd
import pandas_datareader.data as web
impor
在运行加密货币RNN的sentdex教程脚本时,请在此处链接
,
但是在试图训练模型时遇到了一个错误。我的tensorflow版本为2.0.0,我正在运行python3.6。当试图训练模型时,我会收到以下错误:
File "C:\python36-64\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 734, in fit
use_multiprocessing=use_multiprocessing)
File "C:\python36-64\lib\site-
我一直在尝试训练一个keras模型,但它在第一个时代的开始就一直停滞不前。最糟糕的是它没有抛出任何错误。我正在GTX 1050TI上训练
下面是我的代码示例:
import tensorflow as tf
import os
from tensorflow import keras
from keras_preprocessing.image import ImageDataGenerator
from keras_applications.xception import Xception
import matplotlib.pyplot as plt
train_dir='
I tried running this command but i get erros that i dont have tenserflow 2.2 or higher. But I checked and I have the correct version of tenserflow. I also did pip3 install keras command ,我知道所有的代码都是正确的,因为前几天它对我的老师是有效的,并且没有任何改变。我只需要运行他的命令,但我总是遇到问题 我按照他在录制的视频中所做的一切来做这门课,所以肯定没有问题,但由于某种原因,它就是不起作用
我有6类图像,并试图通过基于MobileNetv2的迁移学习来训练一个模型。
我首先创建一个ImageDataGenerator,然后使用“子集”特性将其拆分为单独的列车和测试流。
# Rescale all images by 1./255 and apply image augmentation
train_test_datagen = keras.preprocessing.image.ImageDataGenerator(
rescale=1./255,
validation_split=0.5)
# Flow training images in batches o
我正试图在Keras中训练一个网络来对图像进行分类,在调试完最后一个问题后,得到了一个意想不到的关键工作时代
muiruri_samuel@training-2:~/google-landmark-recognition-challenge$ python train.py
Using TensorFlow backend.
Found 981214 images belonging to 14951 classes.
Found 237925 images belonging to 14951 classes.
Epoch 1/1
2018-03-15 13:35:19.822304: I
正如您在标题中所看到的,我的keras.utils.Sequence返回3个数组。如何使用model.fit(..)3个来自keras.utils.Sequence对象的输出。
def __getitem__(self, index):
'Generate one batch of data'
# Generate indexes of the batch
indexes = self.indexes[index*self.batch_size:(index+1)*self.batch_size]
# F
我想使用keras建立一个RNN模型来对句子进行分类。
我尝试了以下代码:
docs = []
with open('all_dga.txt', 'r') as f:
for line in f.readlines():
dga_domain, _ = line.split(' ')
docs.append(dga_domain)
t = Tokenizer()
t.fit_on_texts(docs)
encoded_docs = t.texts_to_matrix(docs, mode='co
当我试图在LSTM模型中添加validation_split时,我得到了以下错误
ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found: (<tensorflow.python.keras.preprocessing.sequence.TimeseriesGenerator object)
这是密码
from keras.preprocessing.sequence import TimeseriesGenerator
train_generator = Timeseries
我正在训练一个神经网络(2个conv层和1个密集的隐藏层)来对24个字母的手语图像进行分类(J和Z没有图像)。使用ImageDataGenerator的flow()函数创建培训和测试数据生成器。利用Keras序列建立神经网络模型。在训练过程中,我会遇到以下错误:
model = create_model()
# Train your model
history = model.fit(train_generator,
epochs=15,
validation_data=validation_generator)
我做了一个接受两个输入的模型。当我用两个numpy数组来拟合模型时,它可以工作。下面是一个例子:
model.fit(x=[image_input, other_features], y = y, epochs=epochs)
但是,我的问题是,other_features是一个numpy数组,而image_input使用tf.keras.preprocessing.image_dataset_from_directory加载keras。我面临的问题是:
如何从image_input中正确地给y?当我只使用一个输入image_input训练模型时,y被打包在其中,所以我不必在另一个y中指定它才
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
import os
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.layers import Flatten, Dropout, Conv2D, MaxPool2D
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Seque
设计了具有动态输入量的神经网络。我的想法是用共享模型处理数据集,然后平均/最大地处理它们的结果,并在其上放置分类器。在阅读了文档之后,我确信使用Keras是可能的,但我面临的问题是keras.layers.average只能接收输入张量。但是我需要对模型或其他层进行这个操作。
这是我现在的代码
inputs = [Input((countInputCount,))] # count is always here
downs = []
for i in range(count):
inputs.append(Input((inputCount,)))
downs
该代码在tensorflow==1.14和keras==2.2.4中运行良好:
def data_generator(images, descriptions, VGG16) :
while True :
for i in range(0, len(images)) :
feature = VGG16.predict(images[i]);
#variable description includes what the people are doing in this image : ["a man is cook
我正在学习“物理层深度学习导论”。
在用python keras实现所提出的网络时,我应该规范一些层的输出。
一种方法是简单L2规范化(||X||^2 = 1),其中X是前一层输出的张量。我可以通过以下代码实现简单的L2规范化:
from keras import backend as K
Lambda(lambda x: K.l2_normalize(x,axis=1))
另一方面,我想知道的是||X||^2 ≤ 1。有没有限制层输出值的方法?
我正在学习DCGAN的这个教程,并试图从我保存的检查点恢复一个模型。但是当我尝试加载模型时,它给出了一个错误:
AssertionError: Nothing except the root object matched a checkpointed value. Typically this means that the checkpoint does not match the Python program. The following objects have no matching checkpointed value: [<tensorflow.python.keras.lay
我必须在丹瑟尔·弗洛发球时为凯拉斯模型服务。为此,我试图使用此脚本将keras模型转换为tf saved_model格式。
from tensorflow.keras.layers import Input
from tensorflow.keras import backend as K
import networks.generator as gen
import tensorflow as tf
K.set_learning_phase(0)
encoder = gen.encoder(3, 224)
encoder.load_weights(f"weights/encoder
通常,在使用functional定义模型时,可以从任何原始模型层开始和结束构建子模型。例如,考虑以下代码:
inp = tf.keras.Input((4,))
y = tf.keras.layers.Dense(4, name="od_1")(inp)
y = tf.keras.layers.Dense(2, name="od_2")(y)
y = tf.keras.layers.Dense(4, name="id_1")(y)
y = tf.keras.layers.Dense(10, name="od_3")(y)
y =
我正在尝试使用InceptionV4来解决一些分类问题。在用它解决这个问题之前,我正试着用它来做实验。
我用一个新的稠密层替换了最后一个密集层(大小为1001),编译了模型并尝试拟合它。
from keras import backend as K
import inception_v4
import numpy as np
import cv2
import os
from keras import optimizers
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Seq