我正在使用 Tensorboard 绘制实验损失图。
我还想将测试结果添加到 Tensorboard 以便于实验比较,但我找不到执行此操作的函数。
我只需要一个简单的表,例如:
| Exp name | Metric 1 | Metric 2 |
|----------|----------|----------|
| Exp 1 | 12 | 123 |
| Exp 2 | 23 | 234 |
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现这个目标?
我正在使用 PyTorch 版本的SummaryWriter.
我的函数需要接受一个对象,可以通过索引viz从中提取数据。一个List或限定的实例__getitem__方法。
提示该参数的类型可以使用哪种类型?
更新:据我了解,目前还没有这种类型,我试图自己做一个:
class IndexableContainer(Generic[int, ReturnType]):
def __getitem__(self, key: int) -> ReturnType:
...
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
File "indexable_container.py", line 22, in IndexableContainer
class IndexableContainer(Generic[int, ReturnType]):
File ".../lib/python3.6/typing.py", line 682, in inner
return func(*args, **kwds)
File ".../lib/python3.6/typing.py", line 1112, in __getitem__
"Parameters to Generic[...] must all be type variables")
TypeError: Parameters to Generic[...] must all be type variables
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我正在尝试针对模式测试许多json文档,并且我使用具有所有必需字段名称的对象来保持每个文件具有多少错误.
在任何python库中是否有一个函数创建一个样本对象,其中包含是否需要特定字段的布尔值.即从这个架构:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"type": {
"type": "string"
},
"position": {
"type": "array"
},
"content": {
"type": "object"
}
},
"additionalProperties": false,
"required": [
"type",
"content"
]
}
Run Code Online (Sandbox Code Playgroud)
我需要得到类似的东西:
{
"type" : True,
"position" : False,
"content" : True
}
Run Code Online (Sandbox Code Playgroud)
我也需要它来支持对定义的引用
我目前有一个带有许多可选参数的函数,如下所示:
def many_argument_function(required1, required2, optional1=1, optional2=2,
optional3=None, optional4="Test", optional5="g",
optional6=2, optional7=(0, 255, 0), optional8=0.5):
# Do stuff
Run Code Online (Sandbox Code Playgroud)
但实际上,它有20多个可选参数,即使有120个字符的行数限制,它们也要占用5行。
是否有一种设计模式可以简化/使其更漂亮?
PS我考虑过为此功能创建一个单独的配置文件,但是随后调用它会很麻烦,因为在大多数情况下,仅使用一个或两个可选参数。
EDIT1:我不想使用,kwargs因为我希望在IDE(PyCharm)中显示参数名称和默认值