我正在构建一个简单的待办事项列表应用程序.我试图通过将它们相对于彼此定位来组织我的布局.我通过调用XML属性来做到这一点android:layout_toStartOf="@id/to_do_btn"但是我收到了一个No Resource Found That Matches The Given Name错误.我基本上尝试了Stackoverflow上的每个解决方案但没有任何帮助.这是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="myapp.onur.todo.MainActivity">
<ListView
android:id="@+id/to_do_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="@id/to_do_btn"
android:layout_margin="5dp"
>
</ListView>
<EditText
android:id="@+id/to_do_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Something To Do"
android:layout_toStartOf="@id/to_do_btn"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignTop="@id/to_do_btn"
android:layout_below="@id/to_do_list"
android:layout_margin="5dp"
/>
<Button
android:id="@+id/to_do_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="add item"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是错误的一个例子: Error:(15, 31) No resource found that matches the given name (at 'layout_above' with value '@id/to_do_btn').
我不知道是怎么回事.如果它有帮助,这是我的gradle依赖项:
dependencies {
compile fileTree(include: ['*.jar'], dir: …Run Code Online (Sandbox Code Playgroud) 我正在尝试用C++构建Bulls&Cows游戏.我已经实现了大部分逻辑.游戏使用无限循环连续运行,并在每次运行时生成随机值.
我现在要做的是现在是输入用户输入并在输入有效时运行代码(只能是4位整数).这是我的实施:
#include ...
using namespace std;
vector<int> getDigits(int modelValue) {
vector<int> vectorValue;
int extractedDigit = 0;
int modulant = 10000;
int divisor = 1000;
for (int i = 0; i < 4; i++) {
extractedDigit = (modelValue % modulant) / divisor;
vectorValue.push_back(extractedDigit);
modulant /= 10;
divisor /= 10;
}return vectorValue;
}
int main() {
for (;;) {
int model = rand() % 9000 + 1000;
int guess = 0000;
int bulls = 0;
int cows = 0;
int counter …Run Code Online (Sandbox Code Playgroud) 我正试图解决Kaggle的泰坦尼克号生存计划.这是我实际学习机器学习的第一步.我有一个问题,性别列导致错误.堆栈跟踪说could not convert string to float: 'female'.你们是怎么遇到这个问题的?我不想要解决方案.我只是想要一个实用的方法解决这个问题,因为我确实需要性别列来构建我的模型.
这是我的代码:
import pandas as pd
from sklearn.tree import DecisionTreeRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_absolute_error
train_path = "C:\\Users\\Omar\\Downloads\\Titanic Data\\train.csv"
train_data = pd.read_csv(train_path)
columns_of_interest = ['Survived','Pclass', 'Sex', 'Age']
filtered_titanic_data = train_data.dropna(axis=0)
x = filtered_titanic_data[columns_of_interest]
y = filtered_titanic_data.Survived
train_x, val_x, train_y, val_y = train_test_split(x, y, random_state=0)
titanic_model = DecisionTreeRegressor()
titanic_model.fit(train_x, train_y)
val_predictions = titanic_model.predict(val_x)
print(filtered_titanic_data)
Run Code Online (Sandbox Code Playgroud) 当我尝试python3 module_7.py在终端上运行时,出现以下错误:
File "/opt/CarlaSimulator/PythonClient/live_plotter.py", line 227, in plot_figure
tkagg.blit(photo, fca.get_renderer()._renderer, colormode=2)
AttributeError: module 'matplotlib.backends.backend_tkagg' has no attribute 'blit'
Run Code Online (Sandbox Code Playgroud)
我检查了 matplotlib 安装,一切似乎都很好。使用CARLA模拟器时会出现此问题。有一些建议的修复方案,例如在 pyplot 导入之前添加 backend_tkagg 导入,但它没有解决问题。
我在本地运行我的笔记本以使用我自己的 GPU。与 Colab 不同,我在本地实例方面遇到了一些问题。当我运行这个单元格时:
\n\nnp.random.seed(42)\ndata = ImageList.from_folder(path).split_by_rand_pct(valid_pct=0.2).label_from_re(pat=file_parse).transform(size=224).databunch()\nRun Code Online (Sandbox Code Playgroud)\n\nI\xe2\x80\x99m 收到此错误:
\n\n/home/onur/.local/lib/python3.6/site-packages/torch/nn/functional.py:2854: UserWarning: The default behavior for interpolate/upsample with float scale_factor will change in 1.6.0 to align with other frameworks/libraries, and use scale_factor directly, instead of relying on the computed output size. If you wish to keep the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. \n warnings.warn("The default behavior for interpolate/upsample with float scale_factor will change "\n/home/onur/.local/lib/python3.6/site-packages/torch/nn/functional.py:2854: UserWarning: The default behavior for interpolate/upsample with …Run Code Online (Sandbox Code Playgroud) computer-vision neural-network python-3.x conv-neural-network jupyter
我正在尝试使用 YOLOv5x 构建一个对象检测系统。我通过 Roboflow 网站创建了我的数据集,并将该数据集下载到我的笔记本后,我运行以下命令来开始训练:
!curl -L "https://app.roboflow.com/ds/[DATASET-LINK]" > roboflow.zip; unzip roboflow.zip; rm roboflow.zip
Run Code Online (Sandbox Code Playgroud)
但我对每张图像都收到此错误:
train: WARNING: Ignoring corrupted image and/or label /content/yolov5/train/images/output_0446_png.rf.caced7dfbd9c68fe51180ceb8c2f04e8.jpg: duplicate labels
train: WARNING: Ignoring corrupted image and/or label /content/yolov5/train/images/output_0450_png.rf.808e3c83dd6b516900257848467d9a5b.jpg: duplicate labels
train: WARNING: Ignoring corrupted image and/or label /content/yolov5/train/images/output_0456_png.rf.898ad055d9c4cf67db7657c4901db2b7.jpg: duplicate labels
train: WARNING: Ignoring corrupted image and/or label /content/yolov5/train/images/output_0459_png.rf.8bc9567fac8542598a79c2bf11d4d8d5.jpg: duplicate labels
train: WARNING: Ignoring corrupted image and/or label /content/yolov5/train/images/output_0461_png.rf.62c902b73e1b6a92e1417b90c8dd3c9c.jpg: duplicate labels
train: WARNING: Ignoring corrupted image and/or label /content/yolov5/train/images/output_0462_png.rf.bf025028cd9eb5fe98d3cd80452a8d86.jpg: duplicate labels
train: WARNING: Ignoring corrupted image …Run Code Online (Sandbox Code Playgroud) 我在 Julia 中有这个 for 循环:
begin
countries_data_labels = ["Canada", "Italy", "China", "United States", "Spain"]
y_axis = DataFrame()
for country in countries_data_labels
new_dataframe = get_country(df, country)
new_dataframe = DataFrame(new_dataframe)
df_rows, df_columns = size(new_dataframe)
new_dataframe_long = stack(new_dataframe, begin:end-4)
y_axis[!, Symbol("$country")] = new_dataframe_long[!, :value]
end
end
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
syntax: extra token ")" after end of expression
Run Code Online (Sandbox Code Playgroud)
我决定注释除第一个循环之外的所有 for 循环体,并在取消注释后每次都运行单元格以查看哪一行抛出了这个错误,它是体中的第 4 行:
new_dataframe_long = stack(new_dataframe, begin:end-4)
Run Code Online (Sandbox Code Playgroud)
没有理由存在此错误。该系列中没有额外的支架件。
这是来自图像的注释文件:
0 0.6142131979695431 0.336 0.467005076142132 0.392
Run Code Online (Sandbox Code Playgroud)
第一个0是类标签。0.6142131979695431和0.336是边界框的 x 和 y 坐标。0.467005076142132和0.392是边界框的宽度和高度。但是,我不明白的是为什么 x、y、宽度和高度都在 [0,1] 浮点区间内。有人告诉我这是一个百分比,但是相对于什么的百分比呢?
例如,我正在编写构建合成数据集的软件。这是我制作的一张训练图像。它在我想要检测的对象周围有边界框。
边框完美地包裹了 Wizards 和 Ubuntu 徽标。那么,我该如何像上面的格式一样注释它们呢?
我正在执行leetcode,我的代码给了我我无法理解的错误。我被要求反转整数,这很容易做到。这些是测试用例:
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Run Code Online (Sandbox Code Playgroud)
我发现我所需要的只是if语句来检查输入的条件,所以这就是我所做的:
class Solution:
def reverse(self, x: int) -> int:
string = str(x)
lst = list(string)
lst.reverse()
if((lst[0]) == '0'):
lst.pop(0)
if((lst[-1] == '-')):
lst.pop(-1)
lst.insert(0, '-')
output = ''.join(lst)
return output
Run Code Online (Sandbox Code Playgroud)
但是这一行if((lst[-1] == '-')):抛出一个IndexError: list index out of range错误。我正在做的是访问列表的最后一个元素。我不尝试访问不存在的索引。
我唯一需要知道的是为什么会发生此错误。因为这是leetcode,所以我想自己修复该代码。
最终密码
class Solution:
def reverse(self, x: int) -> int:
lst = list(str(x))
lst.reverse()
if(x < 0):
lst.pop(-1) …Run Code Online (Sandbox Code Playgroud) 我driving_log.csv为模拟器创建的每个图像的文件路径创建了一个 CSV 文件 ( ),但当时我使用的是我兄弟的 Windows 计算机,因此现在每个图像的文件路径如下所示(其中几乎有 14000 个图像)。从 my 调用它时出现错误file.py,该文件与 CSV 文件位于同一目录中。
C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\center_2020_02_08_14_16_38_988.jpg,C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\left_2020_02_08_14_16_38_988.jpg,C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\right_2020_02_08_14_16_38_988.jpg,0,0,0,7.918889E-06
Run Code Online (Sandbox Code Playgroud)
我正在使用 Arch Linux。我想遍历每一行并将其更改为:
/home/onur/Documents/behavioral-cloning-CARLA/IMG/center_2020_02_08_14_16_38_988.jpg,left_2020_02_08_14_16_38_988.jpg,right_2020_02_08_14_16_38_988.jpg,0,0,0,7.918889E-06
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我需要接下来的一切\IMG\。
解决这个问题的最佳方法是什么?我应该只对每个字符串进行切片IMG\并获取其后面的内容还是使用正则表达式?
我已经针对该特定行尝试过此操作,看看它是否有效,但它不起作用:
string = r"C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\center_2020_02_08_14_16_38_988.jpg,C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\left_2020_02_08_14_16_38_988.jpg,C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\right_2020_02_08_14_16_38_988.jpg,0,0,0,7.918889E-06 "
new_string = string.replace(r"'C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\'", r"'/home/onur/Documents/behavioral-cloning-CARLA/IMG/'", 3)
print(new_string)
Run Code Online (Sandbox Code Playgroud)
这是输出:
C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\center_2020_02_08_14_16_38_988.jpg,C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\left_2020_02_08_14_16_38_988.jpg,C:\Users\a-ozb\Desktop\onur\behavirol-cloning-carla\IMG\right_2020_02_08_14_16_38_988.jpg,0,0,0,7.918889E-06
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Hackerrank 上解决这个问题:
我有这个输入:
........#....#..#..#....#...#..#.#.#.#.#.#..#.....
..#..#..#.#....#..#.....#......#..##...........##.
.........#.###.##...#.....##......###............#
....##........#..#.#.#......#...#.##.......##.....
.................###...#.#...#......#.#.#.#.#...#.
.........#.....#...........##....#.#.#.##.....##..
.....#.##............#....#......#..#..#...##.....
.#.......###....#.#..##.##.#...##...#........#...#
..#.##..##..........#..........##.....##..........
#.#..##......#.#.#..##.###...#.........###..#...#.
.#..#..............#...#........#..#...#....#..#..
##..#..#........#....#........#...#.#......#.....#
#.#.......#.#..#...###..#..#.##...#.##.......#...#
#.#...#...#.....#....#......##.#.#.........#....#.
.#..........#......##..#....#....#.#.#..#..###....
#.#............#.##..#.##.##......###......#..#..#
.#..#.##...#.#......................#........#....
.....#....#.#..........##.#.#................#....
##............#.#......####...#.........#..##..#..
....#..##..##...#.........##..##....#..#.##...#...
.#........#...#..#...........#.###.....##.....##..
.......#..#..##...#..###.....#..##.........#......
...#......#..#...........###...............#......
...##.###.#.#....#...#..#.#.#....#....#.##.#...#..
..........#.......#..#..#...###....##.....#..#....
.............##.##.#.......#.#....#.......#..#..#.
.......#........#.....#....##...#...#.#...#.#.##..
.....#..#..#........#..#.....#...#.##.#....#...#..
....................#.#...#....###...###...##...#.
##.#.....##.....#..#.#.#...........#.#.##...#..#.#
#...........#....#.##...#.#.....#...#.....#.#.....
..#..##...#........#.##..#.....##.......#...#.#.#.
......#....#...##...........#..#.......#.##.......
......#..#..#.###..........#...#...........#..#...
....#.#..#..#.#.#...#.......#...#.##......#.......
....#.......#..#........#...#.#...#......#.......#
.#....##...#.#..#....#.#.##........#..#.#.........
#....#.......#..##......##...............#..#.##..
...#..##.......#.....#....#...#.#......#..##..###.
.....#...#...#...#...#...#..##...#..#.............
....##......#...#..#...#...#.#....#.....#..#.##...
...##.......#..##.....#........#.#....#...#.......
..#...#....#...#.###......#................#......
...#...###...#..##...###.....................#....
.....#....#....#...#.#.#.##....##......#....##....
...#.###...##.........#..........#.##.#.....#.....
##..#...#.........#.......#......##...........####
...###.#..........#.....#####........#..#.#.#...#.
...#..#.....#..##.##.#.....##...#...#.#.....#...##
.##.......#.##....#............#..................
#.....#.........#.#.........#..###....##...##.....
#....#.....#...#.....#.##...##...####........#....
#...........#..#...#........#.##..##..#...#.#.....
..#.#................#......###..##.#.#...##...#..
.#.#....#..#............#....#......#............#
..#..#...#.#.#...#...........#.......##.#...#.#...
#..........#.....#.....#......#.......#.#...##....
.......#...........#...........#....#............#
...####.#.....#.##.....#.......##.#..#......#.....
.#..#.....#..#......#.............#.#.#..##...#...
..#.#.#.........#...#..#.......#................##
.#..##.#.#...#.............#..#..........#..#...#.
....#........#......#...###..#.#..................
#..#..#.....#.#.#...##....##........#........#....
.....#.#.......##.......#.....#........#..##..#...
#.#.##........#..##.#..#.#...#........#.#......#..
....#.#.#.......#.##.##...##...#..#.###...#.#.#...
.....##.#....#........#....#.#........#.#.#.....#.
.....#..##..#.#....#.......#...#.#.###.........#.#
#.....#.##..#.......###.........#..##..#......##..
Run Code Online (Sandbox Code Playgroud)
70 行,maxTime 为 2244
这是我的策略,但它适用于某些测试用例:
import …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用在图像顶部添加叠加层cv2.addWeighted(...),但它会引发以下错误:
dst = cv2.addWeighted(logo, alpha, overlay, 1-alpha, 0)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-99ib2vsi/opencv/modules/core/src/arithm.cpp:691: error: (-5:Bad argument) When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified in function 'arithm_op'
Run Code Online (Sandbox Code Playgroud)
这个错误对我来说没有意义,因为我检查了文档并且我的论点是适当的。这是我的代码。
def overlay(path):
logo = cv2.imread(path, cv2.IMREAD_UNCHANGED)
alpha = logo[:, :, 3]
overlay = np.zeros(logo.shape, dtype=np.uint8)
overlay[:, :, 2] = alpha
overlay[:, :, 3] = alpha
alpha = 0.5
dst = cv2.addWeighted(logo, alpha, overlay, 1-alpha, 0)
pil_image = Image.fromarray(dst).convert('RGBA')
return pil_image
Run Code Online (Sandbox Code Playgroud)
更新
所以覆盖现在可以工作,但存在一些问题。我对我的代码进行了以下更改: …
我有以下地图:
std::map<char, std::pair<int, int> > robots;
Run Code Online (Sandbox Code Playgroud)
如果输入满足某些条件,我将使用此函数来填充地图:
bool World::addRobot(int row, int col, char robot_name) {
// This if block checks if the desired location is a valid 1 and keeps a track of all the robots already in the grid
if (map_[row][col] == '1' && robots.find(robot_name) == robots.end()){
map_[row][col] = robot_name;
robots.insert(make_pair(robot_name, std::make_pair(row, col)));
}
else{std::cout << "Invalid input" << std::endl;}
return true;
}
Run Code Online (Sandbox Code Playgroud)
每个机器人名称(只是一个字符)都与其位置(行/列坐标)一起保存。在以下函数中,我希望能够检索给定机器人名称的位置对:
std::pair<int, int> World::getRobot(char robot_name) {
std::pair<int, int> location = robots.find(robot_name);
return location;
}
Run Code Online (Sandbox Code Playgroud)
但名称location …
python ×8
c++ ×2
algorithm ×1
android ×1
gradle ×1
graph-theory ×1
index-error ×1
julia ×1
jupyter ×1
linux ×1
matplotlib ×1
numpy ×1
opencv ×1
overlay ×1
pandas ×1
pluto.jl ×1
python-3.x ×1
regex ×1
roboflow ×1
scikit-learn ×1
std-pair ×1
stdmap ×1
stl ×1
syntax-error ×1
windows ×1
xml ×1
yolo ×1
yolov5 ×1