轻许诺言

文章 评论 浏览 31

轻许诺言 2025-02-20 08:59:08

正常算术是基本10,因此小数代表十分之一,百分之十

。积分存储为整数mantissas和指数。 Mantissa代表着重要的数字。指数就像科学符号一样,但它使用2的碱基而不是10。例如,64.0将以1的mantissa表示,指数为6。0.125将以1的Mantissa为1,指数为-3。

浮点小数必须将负2

0.1b = 0.5d
0.01b = 0.25d
0.001b = 0.125d
0.0001b = 0.0625d
0.00001b = 0.03125d

等负功率添加。

在处理浮点算术时,通常使用错误的delta而不是使用平等运算符。而不是

if(a==b) ...

你会使用

delta = 0.0001; // or some arbitrarily small amount
if(a - b > -delta && a - b < delta) ...

Normal arithmetic is base-10, so decimals represent tenths, hundredths, etc. When you try to represent a floating-point number in binary base-2 arithmetic, you are dealing with halves, fourths, eighths, etc.

In the hardware, floating points are stored as integer mantissas and exponents. Mantissa represents the significant digits. Exponent is like scientific notation but it uses a base of 2 instead of 10. For example 64.0 would be represented with a mantissa of 1 and exponent of 6. 0.125 would be represented with a mantissa of 1 and an exponent of -3.

Floating point decimals have to add up negative powers of 2

0.1b = 0.5d
0.01b = 0.25d
0.001b = 0.125d
0.0001b = 0.0625d
0.00001b = 0.03125d

and so on.

It is common to use a error delta instead of using equality operators when dealing with floating point arithmetic. Instead of

if(a==b) ...

you would use

delta = 0.0001; // or some arbitrarily small amount
if(a - b > -delta && a - b < delta) ...

浮点数学破裂了吗?

轻许诺言 2025-02-20 06:56:23

您的问题看起来是因为您的参数是没有长度的。 nvarchar 1 ,因此仅接收到错误的值。更好的数据类型将是 char(3),它是固定长度的,因为所有货币都有精确的三个字母的名称。

您还应该将此功能转换为表值函数,该功能可能会表现更好。

CREATE OR ALTER FUNCTION dbo.getFiatProfit (
    @fiatInvested float,
    @fiatInvestedCurrency char(3),
    @quantity float,
    @currency char(3)
)
RETURNS TABLE
AS RETURN

SELECT
  result = ((@quantity * u.Value) - @fiatInvested)
    / (CASE WHEN @fiatInvestedCurrency = 'USD'
        THEN 1
        ELSE
          (SELECT u2.Value FROM dbo.usdtPairs u2 WHERE u2.ID = 'GBP')
       END)
FROM dbo.usdtPairs u
WHERE u.ID = @currency;

你这样用它

SELECT t.*, fp.*
FROM YourTable t
CROSS APPLY dbo.getFiatProfit(t.fiatInvested, t.fiatInvestedCurrency, t.Qty, 'GBP') fp;

Your issue looks it's because your parameters are declared without a length. nvarchar defaults to a length of 1 in a lot of circumstances, so it's simply the wrong value being received. A much better data type would be char(3) which is fixed length, given that all currencies have exact three-letter names.

You should also convert this function into a Table Valued Function, which is likely to perform far better.

CREATE OR ALTER FUNCTION dbo.getFiatProfit (
    @fiatInvested float,
    @fiatInvestedCurrency char(3),
    @quantity float,
    @currency char(3)
)
RETURNS TABLE
AS RETURN

SELECT
  result = ((@quantity * u.Value) - @fiatInvested)
    / (CASE WHEN @fiatInvestedCurrency = 'USD'
        THEN 1
        ELSE
          (SELECT u2.Value FROM dbo.usdtPairs u2 WHERE u2.ID = 'GBP')
       END)
FROM dbo.usdtPairs u
WHERE u.ID = @currency;

You use it like this

SELECT t.*, fp.*
FROM YourTable t
CROSS APPLY dbo.getFiatProfit(t.fiatInvested, t.fiatInvestedCurrency, t.Qty, 'GBP') fp;

标量值函数返回null

轻许诺言 2025-02-20 06:50:43

这是你想要的吗?

# Python program to print all heading tags
import requests
from bs4 import BeautifulSoup
 
# scraping a wikipedia article
url_link = 'https://www.britannica.com/place/Alabama-state'
request = requests.get(url_link)
 
Soup = BeautifulSoup(request.text, 'lxml')
 
# creating a list of all common heading tags
heading_tags = ["h1", "h2", "h3"]
for tags in Soup.find_all(heading_tags):
    print(tags.name + ' -> ' + tags.text.strip())

结果:

在此处输入图像描述“

Is this what you want?

# Python program to print all heading tags
import requests
from bs4 import BeautifulSoup
 
# scraping a wikipedia article
url_link = 'https://www.britannica.com/place/Alabama-state'
request = requests.get(url_link)
 
Soup = BeautifulSoup(request.text, 'lxml')
 
# creating a list of all common heading tags
heading_tags = ["h1", "h2", "h3"]
for tags in Soup.find_all(heading_tags):
    print(tags.name + ' -> ' + tags.text.strip())

Result:

enter image description here

如何使用Beautifutdsoup在Python中找到特定的课程

轻许诺言 2025-02-20 00:33:26

这对我来说非常有效:

const sw: ServiceWorkerGlobalScope = self as unknown as ServiceWorkerGlobalScope;

现在您将 self 替换为 sw ,哪个更有意义,而且您获得了正确的类型。

This worked very well for me:

const sw: ServiceWorkerGlobalScope = self as unknown as ServiceWorkerGlobalScope;

Now you replace self with sw, which kinda makes more sense, and also you get correct types.

vscode typeScript Intellisense错误

轻许诺言 2025-02-19 21:31:18

怎么样。
marginbottom :( platform.os ===“ ios”&amp;&amp; 10)|| (设备。包括(deviceInfo.getModel()&amp;&amp; 30)|| 0;

它可能不完全适合您想要的东西,但是有了一点修改,应该有可能。

How about this.
marginBottom: (Platform.OS === "ios" && 10) || (devices.includes(DeviceInfo.getModel() && 30 ) || 0;

It may not perfectly fit what you want, but with a little modification it should be possible.

棉布错误在设置样式时重复键

轻许诺言 2025-02-19 12:52:44

在我的主机上,我必须执行 brew install openssl ,它安装openssl@3但是 brew -prefix openssl 仍然链接到openssl@1

我需要完全输入建造Python的路径3.9.13。也许有更好的方法来执行前缀链接。

LDFLAGS="-Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl@3/lib" \
CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/openssl@3/include" \
CONFIGURE_OPTS="--with-openssl=/home/linuxbrew/.linuxbrew/opt/openssl@3" \
pyenv install -v 3.9.13

on my host I have to do a brew install openssl, it install openssl@3 but brew --prefix openssl still links to openssl@1

I need to fully type out the path to build python 3.9.13. maybe there is a better way to do a prefix link.

LDFLAGS="-Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl@3/lib" \
CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/openssl@3/include" \
CONFIGURE_OPTS="--with-openssl=/home/linuxbrew/.linuxbrew/opt/openssl@3" \
pyenv install -v 3.9.13

Ubuntu中的Pyenv 22.04:错误:未编译Python SSL扩展。缺少openssl lib?

轻许诺言 2025-02-19 04:47:23

您基本上希望将列转换为行将行转换为列。为此,您可以使用 pivot 操作员。

这为您提供了所需的输出:

WITH your_table AS 
(
  SELECT 'Jan-2022' AS month, 'male' AS gender, 2000 AS sales, 50 AS quantity
  UNION ALL 
  SELECT 'Jan-2022', 'female', 3000, 100
)

SELECT
  month,
  metrics,
  (male + female) AS overall,
  male,
  male / (male + female) AS male_composition,
  female,
  female / (male + female) AS female_composition
FROM
(
  SELECT *
  FROM 
    your_table 
    UNPIVOT(vals FOR metrics IN (sales, quantity))
) PIVOT(SUM(vals) FOR gender IN ('male', 'female'))

You basically want to transform columns into rows and transform rows into columns. For that, you can use the UNPIVOT and PIVOT operators.

This gives you the desired output:

WITH your_table AS 
(
  SELECT 'Jan-2022' AS month, 'male' AS gender, 2000 AS sales, 50 AS quantity
  UNION ALL 
  SELECT 'Jan-2022', 'female', 3000, 100
)

SELECT
  month,
  metrics,
  (male + female) AS overall,
  male,
  male / (male + female) AS male_composition,
  female,
  female / (male + female) AS female_composition
FROM
(
  SELECT *
  FROM 
    your_table 
    UNPIVOT(vals FOR metrics IN (sales, quantity))
) PIVOT(SUM(vals) FOR gender IN ('male', 'female'))

将行转换为列和列成行以在BigQuery中执行计算

轻许诺言 2025-02-19 04:14:01

有两件事:

  1. 您必须初始化首次亮相才能将其写入JSON( get_storage < /a>);
  2. 而且,您必须默认首次亮相 fin 的值在json(get_storage)阅读时;

因此,整个类 mesure 看起来像这样:


class Mesure {
  late int id;
  String status;
  late String mode;
  late String equipementNumero;
  late String temperature;
  late String courant;
  late String debut = "";
  late String fin = "";

  Mesure.init(List<String> values, this.id, this.status) {
    mode = values[0];
    equipementNumero = values[1];
    temperature = values[2];
    courant = values[3];

    if (mode == "display") {
      debut = values[4];
      fin = values[5];
    }
  }

  Mesure.fromJson(Map<String, dynamic> json)
      : id = json['id'],
        status = json['status'],
        mode = json['mode'],
        temperature = json['temperature'],
        equipementNumero = json['equipementNumero'],
        courant = json['courant'],
        debut = json['debut'] ?? '',
        fin = json['fin'] ?? '';

  Map<String, dynamic> toJson() {
    if (mode == "display") {
      return {
        'id': id,
        'status': status,
        'mode': mode,
        'temperature': temperature,
        'equipementNumero': equipementNumero,
        'courant': courant,
      };
    } else {
      return {
        'id': id,
        'status': status,
        'mode': mode,
        'temperature': temperature,
        'equipementNumero': equipementNumero,
        'courant': courant,
        'debut': debut,
        'fin': fin,
      };
    }
  }
}

另外,构造函数中的代码在 tojson 中看起来倒置。在构造函数中不应该像这样的 mode!=“ display” 而不是 mode ==“ display”

  Mesure.init(List<String> values, this.id, this.status) {
    mode = values[0];
    equipementNumero = values[1];
    temperature = values[2];
    courant = values[3];

    if (mode != "display") {
      debut = values[4];
      fin = values[5];
    }
  }

There are 2 things:

  1. You have to initialize debut to make it write to JSON (get_storage);
  2. And, you have to default the values of debut and fin to something when reading from JSON (get_storage);

So, the entire class Mesure would look like this:


class Mesure {
  late int id;
  String status;
  late String mode;
  late String equipementNumero;
  late String temperature;
  late String courant;
  late String debut = "";
  late String fin = "";

  Mesure.init(List<String> values, this.id, this.status) {
    mode = values[0];
    equipementNumero = values[1];
    temperature = values[2];
    courant = values[3];

    if (mode == "display") {
      debut = values[4];
      fin = values[5];
    }
  }

  Mesure.fromJson(Map<String, dynamic> json)
      : id = json['id'],
        status = json['status'],
        mode = json['mode'],
        temperature = json['temperature'],
        equipementNumero = json['equipementNumero'],
        courant = json['courant'],
        debut = json['debut'] ?? '',
        fin = json['fin'] ?? '';

  Map<String, dynamic> toJson() {
    if (mode == "display") {
      return {
        'id': id,
        'status': status,
        'mode': mode,
        'temperature': temperature,
        'equipementNumero': equipementNumero,
        'courant': courant,
      };
    } else {
      return {
        'id': id,
        'status': status,
        'mode': mode,
        'temperature': temperature,
        'equipementNumero': equipementNumero,
        'courant': courant,
        'debut': debut,
        'fin': fin,
      };
    }
  }
}

Also, the code in the constructor looks inverted in toJson. Shouldn't in the constructor be like this mode != "display" instead of mode == "display":

  Mesure.init(List<String> values, this.id, this.status) {
    mode = values[0];
    equipementNumero = values[1];
    temperature = values[2];
    courant = values[3];

    if (mode != "display") {
      debut = values[4];
      fin = values[5];
    }
  }

未经手的异常:将对象转换为编码对象失败:&#x27; Mesure&#x27;的实例

轻许诺言 2025-02-18 04:28:36

我将您的学习率更改为 0.001 ,并且它在不给NAN的情况下运行(尽管没有学习任何东西,因为可以从最大温度中预测最小温度,因此可能不容易学习)。我的猜测是问题在于您的输入/输出数据的规模,即它们在0-40之类的范围内,这对于神经网络来说不是很好 - 这可能会导致学习变得更加不稳定。我建议您首先将输入/输出扩展到 [0,1] [ - 1,1] 的范围内。我将指导您此博客有关实现这一目标的详细信息,他们还更详细地讨论了为什么扩展数据对于使用神经网络学习很重要。

I changed your learning rate to 0.001 and it runs without giving NaNs (albeit not learning anything since predicting min temperature from max temperature in that data may not be easily learned). My guess is the issue is with the scale of your input/output data, i.e. they're in the range of something like 0-40 which isn't great for neural networks - it can cause the learning to go unstable more easily. I would suggest you first scale your inputs/outputs to be in a range of [0, 1] or [-1, 1]. I'll direct you to this blog for details on achieving that, they also discuss in more detail why scaling the data is important for learning with neural networks.

为什么我的损失函数仅返回NAN值?

轻许诺言 2025-02-18 00:40:25

您可以使用 onsubmit 。在

@using (Html.BeginForm("Edit", "Post", FormMethod.Post, new
{ onsubmit="deleteImages()", enctype = "multipart/form-data" }))

第二个选项之前运行onsubmit :(使用jQuery)

$('form').submit(function() {
   deleteImages();
   return true;
});

you can use onsubmit. run onsubmit before post

@using (Html.BeginForm("Edit", "Post", FormMethod.Post, new
{ onsubmit="deleteImages()", enctype = "multipart/form-data" }))

second option: (using jquery)

$('form').submit(function() {
   deleteImages();
   return true;
});

从html.beginform asp.net MVC调用两个操作

轻许诺言 2025-02-17 20:01:44

从主函数上升起变量,然后使其成为RX:

  var localMemberid=Rxn<String>(); // i would like to make this varial global or pass this value to other pages

void main() {
     SecureStorage secureStorage = SecureStorage();

     .......

   SecureStorage.readLocalSecureData('memberid')
      .then((value) => localMemberid.value = value);
   }

然后在loginController上删除字符串? localmemberid; // 和导入 main.dart

localMemberid.value == null
      ? Get.toNamed(Routes.LOGIN)
      : Get.toNamed(Routes.HOME);

Uplift your variable from the main function and make it Rx:

  var localMemberid=Rxn<String>(); // i would like to make this varial global or pass this value to other pages

void main() {
     SecureStorage secureStorage = SecureStorage();

     .......

   SecureStorage.readLocalSecureData('memberid')
      .then((value) => localMemberid.value = value);
   }

And then on your LoginController remove String? localMemberid; // and import main.dart:

localMemberid.value == null
      ? Get.toNamed(Routes.LOGIN)
      : Get.toNamed(Routes.HOME);

我如何访问main中的变量。到扑面而前的其他页面,我正在使用getx状态管理

轻许诺言 2025-02-17 16:59:03

我的sugention是让您使用通用界面...

void SortPeople<T>(HashSet<T> people) 
    where T : IPeople
{
    
}




public class Student : IPeople
{
    public string Name { get; set; }
    public int Id { get; set; }
}

public class Teacher : IPeople
{
    public string Name { get; set; }
    public int Id { get; set; }
}

public interface IPeople
{
    string Name { get; set; }
    int Id { get; set; }
}

My sugestion is for you to use an interface for the generic ...

void SortPeople<T>(HashSet<T> people) 
    where T : IPeople
{
    
}




public class Student : IPeople
{
    public string Name { get; set; }
    public int Id { get; set; }
}

public class Teacher : IPeople
{
    public string Name { get; set; }
    public int Id { get; set; }
}

public interface IPeople
{
    string Name { get; set; }
    int Id { get; set; }
}

如何将哈希集类型传递到方法中

轻许诺言 2025-02-17 10:25:56

您的 find_min 功能不好。我的意思是,如果没有比第一个元素低的元素,则不会返回任何元素。但是,即使有一个 - 根本不会考虑所有其他人 - 返回语句也会破坏循环。
Rigth方法:

def find_min(students):
    minimum = students[0]
    for x in students[1:]:
        if x < minimum:
            minimum = x
    return minimum

Your find_min function is not good. I mean if there is no element lower than the first one, it won't return anything. But even if there is one - all the others won't be considered at all - the return statement will break the loop.
The rigth way:

def find_min(students):
    minimum = students[0]
    for x in students[1:]:
        if x < minimum:
            minimum = x
    return minimum

我试图确定数组中的最小值,但我一直在获得追溯

轻许诺言 2025-02-17 05:42:16

使用flool():

sum += Math.floor(value%2);
value = Math.floor(value/2);

我猜您的算法适用于某些打字语言,整数部门会导致整数

use floor():

sum += Math.floor(value%2);
value = Math.floor(value/2);

I guess your algorithm works for some typed language where integers division results in integers

我一直弄错这个问题。使用JavaScript计数位

轻许诺言 2025-02-17 03:38:22

以下代码提供了最高销售产品的直方图(可能有多个):

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.DataFrame(np.array([['PRODUCT_75',12 ], ['PRODUCT_75',11], ['PRODUCT_75' ,12],['PRODUCT_75',12],['PRODUCT_63',10],['PRODUCT_63',10],['PRODUCT_63',5],['PRODUCT_63',5],['PRODUCT_12',1],['PRODUCT_120',7],['PRODUCT_120',5],['PRODUCT_120',5],['PRODUCT_120',5]]),
                   columns=['Product','Hour'])
df['Hour']= df['Hour'].astype('int')
res = df.groupby(['Product', 'Hour']).size().reset_index()
res.rename(columns={0:'count'},inplace=True)

def histogram(df, product):
    df[df['Product'] == product]['Hour'].hist()
    plt.suptitle(str(product))
    plt.show()

def highest_selling(res,hour):
    highest_selling_product = res[res['Hour']==hour]['Product'][res['count']==res['count'].max()].to_list()
    return highest_selling_product

highest_selling_product = highest_selling(res, 5)

for i in highest_selling_product:
    histogram(df,i)

这导致以下图:

The following code provides histograms of highest selling products (there may be more than one):

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.DataFrame(np.array([['PRODUCT_75',12 ], ['PRODUCT_75',11], ['PRODUCT_75' ,12],['PRODUCT_75',12],['PRODUCT_63',10],['PRODUCT_63',10],['PRODUCT_63',5],['PRODUCT_63',5],['PRODUCT_12',1],['PRODUCT_120',7],['PRODUCT_120',5],['PRODUCT_120',5],['PRODUCT_120',5]]),
                   columns=['Product','Hour'])
df['Hour']= df['Hour'].astype('int')
res = df.groupby(['Product', 'Hour']).size().reset_index()
res.rename(columns={0:'count'},inplace=True)

def histogram(df, product):
    df[df['Product'] == product]['Hour'].hist()
    plt.suptitle(str(product))
    plt.show()

def highest_selling(res,hour):
    highest_selling_product = res[res['Hour']==hour]['Product'][res['count']==res['count'].max()].to_list()
    return highest_selling_product

highest_selling_product = highest_selling(res, 5)

for i in highest_selling_product:
    histogram(df,i)

which results in following plot:
enter image description here

如何找到数据框架的唯一对值(在不同的行和列上)的计数,并在Python中进行可视化?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文