RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-332625

Никита Денисов's questions

Martin Hope
Никита Денисов
Asked: 2022-09-04 15:30:23 +0000 UTC

实现线性回归

  • 0

在实现线性回归时,出现了一个问题:使用梯度下降,损失一次增加几个数量级。损失 - MSE,梯度下降 - 正常。我选择了加州住房数据集作为数据集。在写代码的时候,我依靠了文章。为了不和offset分开工作,我提前在特征矩阵的开头加了一列1。班级代码

class LinearRegression():

  w = None
  alpha = None

  def __init__(self, lr, E=20):
    self.lr = lr
    self.w = np.zeros(X.shape[1] + 1)
    self.E = E

  def loss(self, X, y):
    return np.sum((X @ self.w - y) ** 2) / X.shape[0]

  def grad(self, X, y):
    grad_basic = 2 * np.transpose(X) @ (X @ self.w - y) / X.shape[0]   
    assert grad_basic.shape == (X.shape[1],) , "Градиенты должны быть столбцом из k_features + 1 элементов"
    return grad_basic

  def sgd(self, X, y, E=20):
    self.loss_arr = [self.loss(X, y)]
    for _ in tqdm(range(E)):
      if abs(self.loss_arr[-1]) < 0.1:
        break
      self.w -= self.lr * self.grad(X, y)
      self.loss_arr.append(self.loss(X, y))

  def fit(self, X, y):
    self.sgd(X, y, self.E)

  def get_params(self):
    return self.w

  def get_loss(self):
    return self.loss_arr

  def predict(self, X):
    return X.dot(self.w)

这就是 loss 的行为方式:5.637, 288906709850, 3.250e+22...
同时,解析解被正确找到。它和完整的回归代码可以在notebook中找到。请告诉我哪里出错了

машинное-обучение регрессия
  • 1 个回答
  • 35 Views
Martin Hope
Никита Денисов
Asked: 2020-05-18 19:01:49 +0000 UTC

为什么项目没有部署到heroku?

  • 1

我正在按照 heroku 上部署页面上的说明进行操作。但是在进入这一行(git push heroku master)之后,一切都崩溃了。错误本身:

   [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myfoodserver: Fatal error compiling: invalid target release: 14 -> [Help 1]

我知道问题出在 maven 编译器上,但具体在哪里呢?我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.6.RELEASE</version>
    <relativePath/>
</parent>
<groupId>ru.denisov</groupId>
<artifactId>myfoodserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myfoodserver</name>
<description>Server for MyFood app</description>

<properties>
    <java.version>14</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.2.12</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.heroku.sdk</groupId>
            <artifactId>heroku-maven-plugin</artifactId>
            <version>3.0.2</version>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>13</source>
                <target>13</target>
            </configuration>
        </plugin>
    </plugins>
</build>

java
  • 1 个回答
  • 10 Views
Martin Hope
Никита Денисов
Asked: 2020-04-06 00:04:52 +0000 UTC

为什么我的程序不能正常工作?

  • 0

我在做这个号码。到目前为止,不是很好

class multifilter:

    def judge_half(pos, neg):
        return pos >= neg

    def judge_any(pos, neg):
        return pos >= 1

    def judge_all(pos, neg):
        return neg == 0

    def __init__(self, iterable, *funcs, judge=judge_any):
        self.l = iterable
        self.f = funcs
        self.judge = judge
        self.i = 0

    def __iter__(self):
        return self

    def __next__(self):

        pos, neg = 0, 0
        if self.i >= len(self.l) - 1:
            raise StopIteration
        for i in self.f:
            if i(self.l[self.i]) == True:
                pos += 1
            else:
                neg += 1
        if self.judge(pos, neg) == True:
            self.i += 1
            return next(self)
        else:
            self.i += 1
            return self.l[self.i]    

但它给出了:过滤器无法正常工作。我很可能没有正确理解迭代器的原理。这就是我的想法:当我写 时,for i in multifilter(iterable, funcs, judge_any):我写for i in iter(multifilter(iterable, *funcs, judge_any))和 在循环的每一次传递中,next(). 但是当我写作时会发生什么list(multifilter(iterable, funcs, judge_any))?告诉我一些要阅读或查看迭代器的内容。只是没有哈布尔!他们的抽象类只会让我感到困惑

PS我知道我被要求在上面实现它yeld,但是在我学习基础知识之前,我不想爬到野外

python
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5