Tensorflow如何使用Python检查模型在stackoverflow问题数据集上的表现如何?

Tensorflow是Google提供的一种机器学习框架。它是一个开放源代码框架,与Python结合使用以实现算法,深度学习应用程序等等。它用于研究和生产目的。

可以使用下面的代码行在Windows上安装'tensorflow'软件包-

pip install tensorflow

Tensor是TensorFlow中使用的数据结构。它有助于连接流程图中的边缘。该流程图称为“数据流程图”。张量不过是多维数组或列表。

我们正在使用Google合作实验室来运行以下代码。Google Colab或Colaboratory可以帮助通过浏览器运行Python代码,并且需要零配置和对GPU(图形处理单元)的免费访问。协作已建立在Jupyter Notebook的基础上。

示例

以下是代码片段-

print("Testing the model with new data")
inputs = [
   "how do I extract keys from a dict into a list?",
   "debug public static void main(string[] args) {...}",
]
print("预测分数 ")
predicted_scores = export_model.predict(inputs)
print("Predicting the labels")
predicted_labels = get_string_labels(predicted_scores)
for input, label in zip(inputs, predicted_labels):
   print("问题是: ", input)
   print("预测标签为: ", label.numpy())

代码信用-https://www.tensorflow.org/tutorials/load_data/text

输出结果

Testing the model with new data
预测分数
Predicting the labels
问题是: how do I extract keys from a dict into a list?
预测标签为: b'python'
问题是: debug public static void main(string[] args) {...}
预测标签为: b'java'

解释

  • 当模型中存在文本预处理代码时,它有助于导出模型以进行生产。

  • 这样,简化了部署。

  • 在模型外部使用“ TextVectorization”时,它有助于执行异步CPU处理和缓冲。

猜你喜欢