我正在按照此处的教程(https://cloud.google.com/ai-platform/training/docs/training-jobs#python_1)并使用Python将机器学习模型部署到Google云进行训练。但是,我收到 HttpError 403:“资源项目 my_project 的权限被拒绝。” 错误的原因是“CONSUMER_INVALID”。具体来说,返回的元数据显示使用者是“projects/my_project”,服务是“ml.googleapis.com”。
我去了AI平台,我的项目确实在那里。我请求使用的 API 已为该项目启用,并且环境变量 GOOGLE_APPLICATION_CREDENTIALS 已正确设置。我想知道如何解决这个问题。谢谢!
google-api-client google-api-python-client google-ai-platform
我正在为 tensorflow keras 序列模型的 model.fit() 方法编写自定义 on_train_end 回调函数。回调函数是关于绘制模型所做的预测,因此它涉及将模型的输入转换为一个 numpy 数组并将其输入到 model.predict() 中。我使用 self.model.inputs 来访问输入,这是一个 KerasTensor 对象列表,第 0 个索引是我想要的。我尝试了以下方法
class my_visualizer(tf.keras.callbacks.Callback):
def on_train_end(self, logs=None):
x = tf.keras.backend.eval(self.model.inputs[0])
y_predictions = self.model.predict(x)
Run Code Online (Sandbox Code Playgroud)
但得到了错误
AttributeError: 'KerasTensor' object has no attribute 'numpy'
Run Code Online (Sandbox Code Playgroud)
所以这个方法是针对另一种类型的张量而不是 KerasTensor。我发现其他解决方案适用于 tensorflow 的 Tensor 对象,但不适用于 keras 的 KerasTensor 对象,并且我没有在 keras 文档中找到任何提及实现所需功能的方法。谢谢你的帮助!
遇到一个很奇怪的问题。尝试导入 firebase 时,出现以下错误:
./node_modules/firebaseui/dist/esm.js
Attempted import error: 'app' is not exported from 'firebase/app' (imported as 'firebase').
Run Code Online (Sandbox Code Playgroud)
我的项目的结构是:包含反应客户端文件夹的父文件夹。我在父文件夹中安装了firebase,在父文件夹的firebaseConfig文件中初始化了一个firebase应用程序,然后将其导入到react客户端文件夹中。
后来我尝试在 react 客户端文件夹中安装 firebase 并在其中导入 firebase。奇怪的是,在我在客户端文件夹中安装 firebase 后,在客户端文件夹中执行“npm ls firebase”返回空,即使 firebase 确实在客户端文件夹中的节点模块和 package.json 中。我想知道是什么导致了这个问题。
父文件夹中的 firebaseConfig.js
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
const firebaseConfig = {
......
};
firebase.initializeApp(firebaseConfig);
export default firebase;
Run Code Online (Sandbox Code Playgroud)