我正在做pip install setuptools --upgrade但下面得到错误
Installing collected packages: setuptools
Found existing installation: setuptools 1.1.6
Uninstalling setuptools-1.1.6:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_set.py", line 726, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_install.py", line 746, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
copytree(src, real_dst, symlinks=True)
File …Run Code Online (Sandbox Code Playgroud) 我使用 Huggingface Transformer 在 Pytorch 中微调了一个预训练的 BERT 模型。所有的训练/验证都是在云端的 GPU 上完成的。
在训练结束时,我保存模型和标记器,如下所示:
best_model.save_pretrained('./saved_model/')
tokenizer.save_pretrained('./saved_model/')
Run Code Online (Sandbox Code Playgroud)
这将在saved_model目录中创建以下文件:
config.json
added_token.json
special_tokens_map.json
tokenizer_config.json
vocab.txt
pytorch_model.bin
Run Code Online (Sandbox Code Playgroud)
现在,我saved_model在我的计算机中下载该目录并想要加载模型和标记器。我可以像下面这样加载模型
model = torch.load('./saved_model/pytorch_model.bin',map_location=torch.device('cpu'))
但是我如何加载标记器?我是 pytorch 的新手,不确定因为有多个文件。可能我没有以正确的方式保存模型?
我在我的 Mac 上安装了 LightGBM,并之前针对不同的项目进行了测试。
现在我在 Mac 上安装了 python 3.6 的 docker 中。一旦我添加import lightgbm as lgbm到 Flask 应用程序中,我就会收到错误
OSError: libgomp.so.1: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?有人可以建议吗?
我将RedBearLab BLE屏蔽连接到Arduino UNO R3.我可以使用Rasp-Pi(附带的CSR4.0加密狗)中的gatttool连接到它.我有一些传感器(FSR)连接到模拟引脚,LED连接到Arduino中的数字引脚.我的目标是读取/写入通过BLE连接到Arduino的任何东西.
作为样本,我正在研究这个链接.看来我需要知道传感器的手柄,配置寄存器#等来读/写.但我不知道如何找到与连接到屏蔽的传感器相关的手柄/ uuid.
例如,我在下面看到.
[xx:xx:xx:xx:xx:xx][LE]> char-desc
handle: 0x0001, uuid: 2800
handle: 0x0002, uuid: 2803
handle: 0x0003, uuid: 2a00
handle: 0x0004, uuid: 2803
handle: 0x0005, uuid: 2a01
handle: 0x0006, uuid: 2803
handle: 0x0007, uuid: 2a04
handle: 0x0008, uuid: 2800
handle: 0x0009, uuid: 2800
handle: 0x000a, uuid: 2803
handle: 0x000b, uuid: 713d0003-503e-4c75-ba94-3148f18d941e
handle: 0x000c, uuid: 2803
handle: 0x000d, uuid: 713d0002-503e-4c75-ba94-3148f18d941e
handle: 0x000e, uuid: 2902
handle: 0x000f, uuid: 2800
handle: 0x0010, uuid: 2803
handle: 0x0011, uuid: 2a27
Discover …Run Code Online (Sandbox Code Playgroud) 我已经通过brew安装了pkg-config和libusb
现在如果我这样做
pkg-config --cflags --libs libusb
我收到以下消息
在 pkg-config 搜索路径中找不到软件包 libusb。也许您应该将包含“libusb.pc”的目录添加到 PKG_CONFIG_PATH 环境变量中找不到软件包“libusb”
所以我按照这篇文章做了
导出 PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/Cellar/libusb/1.0.20/lib/pkgconfig"
但我仍然有问题。我缺少什么?
我使用的是 MAC OSX El Capitan
我在 Sagemaker 中部署了基于 TensorFlow/keras 的 CNN 模型。
现在为了调用推论,我遵循了本教程
下面的代码片段
def inferImage(endpoint_name):
# Load the image bytes
img = open('./shoe.jpg', 'rb').read()
runtime = boto3.Session().client(service_name='sagemaker-runtime')
# Call your model for predicting which object appears in this image.
response = runtime.invoke_endpoint(
EndpointName=endpoint_name,
ContentType='application/x-image',
Body=bytearray(img))
response_body = response['Body']
print(response_body.read())
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,出现错误
Unsupported content-type application/x-image
我缺少什么?关于如何修复它有什么建议吗?
我有一个 AWS lambda 函数,我可以同步调用它并使用以下代码返回结果
response = lambda_client.invoke(
FunctionName=FUNCTION_NAME,
InvocationType='RequestResponse',
LogType='Tail',
Payload=payload,
Qualifier=$LATEST
)
Run Code Online (Sandbox Code Playgroud)
响应 Payload 的类型<botocore.response.StreamingBody object at 0x115fb3160>所以我使用下面的代码来提取工作正常的有效负载。
response_body = response['Payload']
response_str = response_body.read().decode('utf-8')
response_dict = eval(response_str)
Run Code Online (Sandbox Code Playgroud)
现在,我需要异步调用我的 lambda,所以我更改了调用类型 InvocationType='Event'
它给了我一个与以前相同类型的有效负载的响应,botocore.response.StreamingBody object但我在这行出现错误 -response_dict = eval(response_str)
错误消息说
response_dict = eval(response_str)
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
Run Code Online (Sandbox Code Playgroud)
我错过了什么?如果响应负载与同步调用的类型相同,为什么会出现解析错误?有什么建议吗?
编辑
为清楚起见,我明白如果InvocationType='Event', 那么我们只得到invoke调用的状态,而不是 lambda 函数的结果。不过,在我的情况下,我需要两者 - 启动 lambda 异步并在完成后返回结果。我怎么做?是否将结果写回 s3 并定期检查这是唯一的选择?
我正在尝试从 AWS lambda 写入 SQS 队列,如下所示。
sqs = boto3.resource(
'sqs',
region_name='us-east-1'
)
def lambda_handler(event, context):
queue_name = event["queue_name"]
sqsQ = sqs.get_queue_by_name(QueueName=queue_name)
msg_body = {
"source": "some_source",
"mse": 120
}
msg = sqsQ.send_message(MessageBody=json.dumps(msg_body), MessageGroupId="some_id", MessageDeduplicationId=str(uuid.uuid4()))
Run Code Online (Sandbox Code Playgroud)
但我收到队列不存在错误
"errorMessage": "An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the GetQueueUrl operation: The specified queue does not exist or you do not have access to it.",
"errorType": "QueueDoesNotExist",
Run Code Online (Sandbox Code Playgroud)
我确保队列名称正确(复制粘贴)并且它是正确的区域。
我缺少什么?
我在本地使用 dynamoDB。我想创建一个具有 6 个属性的表,其中只有一个是key. 我怎么做?keySchema在AttributeDefinitions? 中指定键属性和所有属性?
var params = {
TableName : "Movies",
KeySchema: [
{ AttributeName: "year", KeyType: "HASH"}, //Partition key
],
AttributeDefinitions: [
{ AttributeName: "year", AttributeType: "N" },
{ AttributeName: "title", AttributeType: "S" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
};
dynamodb.createTable(params, function(err, data) {
if (err) {
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
} …Run Code Online (Sandbox Code Playgroud) aws-lambda ×2
python ×2
amazon-sqs ×1
arduino ×1
bluetooth ×1
bluez ×1
json ×1
libusb-1.0 ×1
lightgbm ×1
node.js ×1
pkg-config ×1
python-2.7 ×1
pytorch ×1