我尝试使用GridSearchCV(),但也有错误,所以我编写了一个非常耗时的代码,返回我想要评估我的模型的指标。下面是:
def df_to_new(df,window_size):
df_as_np = df.to_numpy()
X = []
y = []
for i in range(len(df_as_np)-window_size):
row = [[a] for a in df_as_np[i:i+window_size]]
X.append(row)
label = df_as_np[i+wind
我使用Keras的functional构建了一个模型,当我在model.fit()函数中将tensorboard实例添加到回调时,它会引发一个错误:"AttributeError: 'Model' object has no attribute 'run_eagerly'"
模型类确实没有属性run_eagerly,但是在Keras中,它说它可以作为参数传递给model.compile()函数。这会返回
"ValueError: ('Some keys in session_kwargs are not supported at
我试着训练我的模型阅读一些x射线图像,我使用木星笔记本,导入库,定义图像属性,准备数据集,创建神经网络模型,定义回调.并管理数据,但在试图训练我的模型时,我得到了以下错误:
ValueError: Unexpected result of `train_function` (Empty logs). Please use `Model.compile(..., run_eagerly=True)`, or `tf.config.run_functions_eagerly(True)` for more information of where went wrong, or file a iss
python == 3.7.6 Tensorflow = 2.0.0
我已经创建了一个自定义层,它调用一个用@tf.custom_gradient修饰的函数,非常类似于下面问题下面的答案所描述的情况:
但是我总是在运行时收到这个错误:ValueError: The custom_gradient decorator currently supports keywords arguments only when eager execution is enabled.
当在main函数中调用时,函数本身运行得很好。因此,明确地说:
output = custom_function(input)在急
我一直在训练一种图像分类器,可以检测油彩和铅笔画。在这样做时,我遇到了一个值错误。我彻底地搜索了网络,不幸的是,我没有找到任何令人满意的答案,因为没有太多的讨论。
代码:
import tensorflow as tf
import os
import matplotlib.pyplot as plt
gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
tf.config.experimental.set_m
我试着换掉这个 from keras.optimizers import SGD 使用 from tensorflow.keras.optimizers import SGD 但这仍然行不通 以下是我的代码 from tensorflow.keras.optimizers import SGD
from keras.initializers import RandomUniform
from keras.callbacks import TensorBoard
from tensorflow import keras
import tensorflow as tf
init = Rand
目前,我的神经网络精度函数(和神经网络)如下:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras import models
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import LSTM
import numpy as np
d
我用下面的代码尝试了急切执行和禁用急切执行:
model = build_encoder_decoder()
final = build_refinement(model)
final.load_weights('/content/gdrive/My Drive/DIM/models/model.01-0.1296.hdf5')
for layer in final.layers:
layer.trainable = True
import tensorflow as tf
sgd = tensorflow.keras.optimizers.SGD(lr=1e-5, d
我正在复制“Aurélien Géron的手工机器学习”一书第16章的例子,并在试图训练一个简单的RNN模型时发现了一个错误。
错误如下:
ValueError: Unexpected result of `train_function` (Empty logs). Please use `Model.compile(..., run_eagerly=True)`, or `tf.config.run_functions_eagerly(True)` for more information of where went wrong, or file a issue/bug to `tf.ker
我正在使用Tensorflow 2.3,并尝试初始化以下LSTM
from keras.layers import Dense, Activation,Input, LSTM, Dropout
from keras.optimizers import Adam
from keras.models import Model, Sequential
def create_model() -> Model:
"""
Create the Deep Learning model
:return the created model
"
我正在实现一个自定义损失函数,如下面的代码所示,用于简单的分类。但是,当我运行代码时,我得到错误ValueError:没有为任何变量提供渐变: import os
os.environ['KERAS_BACKEND'] = "tensorflow"
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from tensorflow import keras
from tensorflow.keras import layers
from sklearn.prep
我用keras创建了一个预测,例如,如果我重复预测10次,我想看看结果是什么。如果我循环,我会收到警告
WARNING:tensorflow:6 out of the last 6 calls to <function Model.make_predict_function.<locals>.predict_function at 0x1507503a0> triggered tf.function retracing.
我的问题是:如果我像这样循环,是不是一样?
for a in range(1,11):
model = Sequential()
mo
我为一个NLP问题建立了一个模型,并试图用它来做预测。它给出了LSTM和RNN的一个错误:
ValueError: in user code:
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1621, in predict_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.7/dist-packages/keras/engin
从Tensorflow示例中获取必要的代码来对结构化数据进行分类,以便我能够学习如何在数字列上进行培训;我得到了以下错误:
ValueError:尝试将不受支持的类型()的值(63)转换为张量。
虽然我想我可以尝试将dataframe中的特定值转换为使用张量(如果这样可以的话),但是当代码在Colab中工作时,还会发生其他一些事情,但是在PyCharm中会抛出一个错误。
import pandas as pd
import tensorflow as tf
from tensorflow import feature_column
from tensorflow.python.kera
我正在为带有keras后端的神经网络编写一个自定义损失函数,以减少姿态误差。
def LossQuat(y_true, y_pred):
a, b = y_true.get_shape()
error = np.zeros([a,1])
for i in range(a):
w0,x0,y0,z0 = y_true[i,:]
w1,x1,y1,z1 = y_pred[i,:]/tf.norm(y_pred, ord='euclidean', axis=None, keepdims=
由于tflearn已经过时,而且我正在看一个使用tflearn的聊天机器人教程,所以我想用keras编写神经网络模型。但是,我在这里得到了一个错误:
WARNING:tensorflow:Model was constructed with shape (None, 58) for input KerasTensor(type_spec=TensorSpec(shape=(None, 58), dtype=tf.float32, name='input_22'), name='input_22', description="created by laye