我正在尝试在 Google Multilingual Universal Encoder 上重现笔记本。但是,通过下载必要的库tensorflow_text:
%%capture
#@title Setup Environment
# Install the latest Tensorflow version.
!pip3 install tensorflow_text
Run Code Online (Sandbox Code Playgroud)
或者
!python -m pip install tensorflow_text
Run Code Online (Sandbox Code Playgroud)
我进入 jupyter:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-48-399dd4157896> in <module>
8 import tensorflow.compat.v2 as tf
9 import tensorflow_hub as hub
---> 10 from tensorflow_text import SentencepieceTokenizer
11 import sklearn.metrics.pairwise
12
ModuleNotFoundError: No module named 'tensorflow_text'
Run Code Online (Sandbox Code Playgroud)
我尝试使用安装它python -m pip install tensorflow-text,但它给了我:
(seg_env) C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>python -m pip install tensorflow-text …Run Code Online (Sandbox Code Playgroud) 我试图从计算机创建的 pdf 中提取文本并且它有效,但我无法从扫描的 pdf 中提取文本,您可以在此处找到,其中包含图像和几页,例如:
这是我使用的代码:
# libraries
## split
from PyPDF2 import PdfFileWriter, PdfFileReader
## read
import sys
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.pdfpage import PDFPage
from pdfminer.converter import XMLConverter, HTMLConverter, TextConverter
from pdfminer.layout import LAParams
import io
# remove files
import os
# split in case there is several pages
def pdfspliter(filename):
inputpdf = PdfFileReader(open(filename, "rb"))
for i in range(inputpdf.numPages):
output = PdfFileWriter()
output.addPage(inputpdf.getPage(i))
with open("document-page%s.pdf" % i, "wb") as outputStream:
output.write(outputStream)
pdfparser("document-page%s.pdf" % i) …Run Code Online (Sandbox Code Playgroud) 我有一个 Dialogflow 聊天机器人。在 Dialogflow 内部测试器中一切正常,但在 facebook 上显示的版本中,我无法获得卡片或建议。即使我用另一个工作聊天机器人的代码替换它们。
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion, Payload} = require('dialogflow-fulfillment');
var answers = [];
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function welcome(agent) {
agent.add('Hi! Do you want to discover your lockdown personality?');
agent.add(new Card({
title: '1. How has the COVID-19 crisis',
imageUrl: 'https://ejoy-english.com/blog/wp-content/uploads/2018/08/shutterstock_524250877-e1496428580440.jpg',
text: 'impacted the stability of your life?',
})
);
agent.add(new …Run Code Online (Sandbox Code Playgroud) 我设计了自己的损失函数。但是,当尝试恢复到训练期间遇到的最佳模型时
model = load_model("lc_model.h5")
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-105-9d09ef163b0a> in <module>
23
24 # revert to the best model encountered during training
---> 25 model = load_model("lc_model.h5")
C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\saving.py in load_model(filepath, custom_objects, compile)
417 f = h5dict(filepath, 'r')
418 try:
--> 419 model = _deserialize_model(f, custom_objects, compile)
420 finally:
421 if opened_new_file:
C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\saving.py in _deserialize_model(f, custom_objects, compile)
310 metrics=metrics,
311 loss_weights=loss_weights,
--> 312 sample_weight_mode=sample_weight_mode)
313
314 # Set optimizer weights.
C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py in compile(self, optimizer, loss, metrics, loss_weights, …Run Code Online (Sandbox Code Playgroud) 我有一个包含两个类的 MyFirstProgram.java 文件。我只是修改了 Path 并尝试使用java和测试文件javac。
public class MyFirstProgram{
public static void main(String[] args){
System.out.println("Hello ! World :)");
}
}
Run Code Online (Sandbox Code Playgroud)
但是,它返回给我:
C:\Users\antoi\Documents\Programming\Julien>java MyFirstProgram.java
Error: Could not find or load main class MyFirstProgram.java
C:\Users\antoi\Documents\Programming\Julien>javac MyFirstProgram.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
这是路径:
它仅在我直接在文件夹中调用 javac 时才有效:
C:\Users\antoi\Documents\Programming\Julien>"C:\Program Files\Java\jdk-11.0.2\bin\javac" MyFirstProgram.java
C:\Users\antoi\Documents\Programming\Julien>java MyFirstProgram
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: MyFirstProgram …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用pdf2image,看来我需要一个叫做propeller:
(sum_env) C:\Users\antoi\Documents\Programming\projects\summarizer>python ocr.py -i fr13_idf.pdf
Traceback (most recent call last):
File "c:\Users\antoi\Documents\Programming\projects\summarizer\sum_env\lib\site-packages\pdf2image\pdf2image.py", line 165, in __page_count
proc = Popen(["pdfinfo", pdf_path], stdout=PIPE, stderr=PIPE)
File "C:\Python37\lib\subprocess.py", line 769, in __init__
restore_signals, start_new_session)
File "C:\Python37\lib\subprocess.py", line 1172, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ocr.py", line 53, in <module>
pdfspliterimager(image_path)
File "ocr.py", line 32, in pdfspliterimager
pages = convert_from_path("document-page%s.pdf" …Run Code Online (Sandbox Code Playgroud) 我想将数据集类别的权重矩阵传递给神经网络。
from sklearn.utils import class_weight
class_weights = class_weight.compute_class_weight('balanced',
np.unique(y_train),
y_train)
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-93-9452aecf4030> in <module>
2 class_weights = class_weight.compute_class_weight('balanced',
3 np.unique(y_train),
----> 4 y_train)
~\AppData\Roaming\Python\Python36\site-packages\sklearn\utils\class_weight.py in compute_class_weight(class_weight, classes, y)
39
40 if set(y) - set(classes):
---> 41 raise ValueError("classes should include all valid labels that can "
42 "be in y")
43 if class_weight is None or len(class_weight) == 0:
ValueError: classes should include all valid labels that can be in y
Run Code Online (Sandbox Code Playgroud)
我不明白,这是我的y_train …
我想people_preferences根据其段获取以下数据帧的前两列中每一列的平均值Segment。
Fun|Not-Fun Pro-garden|Pro-home Segment
0 NaN NaN cats
1 NaN NaN cats
2 -1.0 NaN cats
... ... ... ...
4570 -1.0 -1.0 dogs
4571 -1.0 1.0 dogs
4572 -1.0 1.0 dogs
Run Code Online (Sandbox Code Playgroud)
所以我尝试了people_preferences.groupby('Segment', as_index=False).mean( skipna = True),但它返回了:UnsupportedFunctionCall: numpy operations are not valid with groupby. Use .groupby(...).mean() instead
这是完整的错误消息:
---------------------------------------------------------------------------
UnsupportedFunctionCall Traceback (most recent call last)
<ipython-input-489-f8da6e73c33c> in <module>
48 pairs = list(itertools.combinations(df_features.columns, 2))
49
---> 50 [plot_mean(pair[0],pair[1]) for pair in pairs]
51
52 …Run Code Online (Sandbox Code Playgroud) 我试图获取由 Dialogflow 聊天机器人使用完整代码构建的 javascript 数组中最常见的项目。但是,如果我可以显示数组,那么我尝试的函数似乎无法很好地找到最频繁的项目:
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
var answers = [];
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand FULLFILMENT`);
agent.add(`I'm sorry, can you try again? FULLFILMENT`);
}
function …Run Code Online (Sandbox Code Playgroud) 我想使用 rsync 将 Docker 映像从 Windows10 PC 传输到另一台 Fedora。我无法使用 WSL,我需要 WSL2,正如编译器所说:
ubu@DESKTOP-QL4RO3V:/mnt/c/Windows/system32$ docker images
The command 'docker' could not be found in this WSL 1 distro.
We recommend to convert this distro to WSL 2 and activate
the WSL integration in Docker Desktop settings.
For details about using Docker Desktop with WSL 2, visit:
https://docs.docker.com/go/wsl2/
Run Code Online (Sandbox Code Playgroud)
但我认为由于我有 Docker 桌面,它正在使用 WSL2:
但我不知道如何运行我自己使用的 wsl2 Docker。
PS C:\Users\antoi> wsl -l -v
NAME STATE VERSION
* Ubuntu Running 1
docker-desktop-data Running 2
docker-desktop Running 2
Run Code Online (Sandbox Code Playgroud) 让是一个具有以下关系方案的数据库:R(A,B,D)并且S(A,B)在同一域中具有相同名称的属性,r并且s分别具有实例和。
一个实例 s
什么是方案,什么是元组u=r÷s?如何用r和用英语定义它们s?
我知道
这让我认为它只会是一个 A 列的数组,但我不确定在数组中会产生什么结果。
你能帮我理解u=r÷s吗?
我发送一个请求,该请求发回如下内容:
{
"items": [
{
"id": 86154,
...
},
{
"id": 86194,
...
}
}
Run Code Online (Sandbox Code Playgroud)
我想在 Postman 测试部分计算这个数组的大小。所以我写道:
var body = JSON.parse(pm.response.json());
tests["Count: " + body.items] = true;
Run Code Online (Sandbox Code Playgroud)
正如您在上面看到的,它没有起作用。我对 PostMan 和 Javascript 都很陌生,这可能就是原因。
我想编写一个函数来检查字典并返回两个键(“名称”和“成本”)以获取“食物”中最大成本的记录:
[{'age': 'Dark',
'armor': '0/1',
'attack': 4,
'build_time': 21,
'cost': {'Food': 60, 'Gold': 20},
'created_in': 'https://age-of-empires-2-api.herokuapp.com/api/v1/structure/barracks',
'description': 'Basic infantry swordsman. Quick and cheap to create',
'expansion': 'Age of Kings',
'hit_points': 40,
'id': 15,
'line_of_sight': 4,
'movement_rate': 0.9,
'name': 'Militia',
'reload_time': 2.0},
{'age': 'Dark',
'armor': '0/0',
'build_time': 30,
'cost': {'Food': 50},
'created_in': 'https://age-of-empires-2-api.herokuapp.com/api/v1/structure/castle',
'description': 'Cannot be produced so the cost and build time just for the sake of interest',
'expansion': 'Age of Kings',
'hit_points': 75,
'id': 20,
'line_of_sight': 6,
'movement_rate': 1.32, …Run Code Online (Sandbox Code Playgroud) python-3.x ×6
python ×5
javascript ×3
json ×2
pandas ×2
tensorflow ×2
windows-10 ×2
arrays ×1
dataframe ×1
dictionary ×1
docker ×1
frequency ×1
group-by ×1
java ×1
keras ×1
mean ×1
path ×1
pdf ×1
postman ×1
rich-media ×1
scikit-learn ×1
text ×1
wsl-2 ×1