小编Kad*_*j13的帖子

number 1e5是什么意思?

我在一些代码中看到,peaple定义了一个变量并分配了例如1e-8或1e5之类的值

const int MAXN = 1e5 + 123;
Run Code Online (Sandbox Code Playgroud)

这些数字是什么?!我在网上找不到任何东西......

numbers

21
推荐指数
2
解决办法
6万
查看次数

CREATE VIEW必须是批处理中的唯一语句

我正试着看一看.到目前为止,我写了这个:

with ExpAndCheapMedicine(MostMoney, MinMoney) as
(
    select max(unitprice), min(unitprice)
    from Medicine
)
,
findmostexpensive(nameOfExpensive) as
(
    select tradename
    from Medicine, ExpAndCheapMedicine
    where UnitPrice = MostMoney
)
,
findCheapest(nameOfCheapest) as
(
    select tradename
    from Medicine, ExpAndCheapMedicine
    where UnitPrice = MinMoney
)

CREATE VIEW showing
as
select tradename, unitprice, GenericFlag
from Medicine;
Run Code Online (Sandbox Code Playgroud)

不幸的是,我在包含的行上收到错误 CREATE VIEW showing

"CREATE VIEW必须是批处理中唯一的声明"

我怎样才能解决这个问题?!

sql sql-server create-view

13
推荐指数
2
解决办法
4万
查看次数

无法找到具有可执行 jekyll 的 gem jekyll (>= 0.a) (Gem::GemNotFoundException)

我正在尝试按照官方网站上的说明使用 github 和 jekyll 制作我的个人网站

当我到达该部分时:

jekyll new --skip-bundle
Run Code Online (Sandbox Code Playgroud)

我收到了:

can't find gem jekyll (>= 0.a) with executable jekyll (Gem::GemNotFoundException)
Run Code Online (Sandbox Code Playgroud)

我尝试了几种方法,例如这里提到的一种方法,我使用 运行命令sudo。再次运行后jekyll new --skip-bundle

这是按照此处的说明安装后的终端响应

Fetching bundler-2.4.5.gem
Successfully installed bundler-2.4.5
Parsing documentation for bundler-2.4.5
Installing ri documentation for bundler-2.4.5
Done installing documentation for bundler after 0 seconds
1 gem installed
Run Code Online (Sandbox Code Playgroud)

这是我jekyll new --skip-bundle再次运行时的终端响应:

Traceback (most recent call last):
    2: from /usr/local/bin/jekyll:22:in `<main>'
    1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:262:in `bin_path'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find …
Run Code Online (Sandbox Code Playgroud)

ruby rubygems ruby-on-rails jekyll github-pages

6
推荐指数
1
解决办法
759
查看次数

参数 #2“mat1”的张量位于 CPU 上,但预计它位于 GPU 上

根据我之前的问题,我编写了这段代码来训练自动编码器,然后提取特征。(变量名可能有一些变化)

# Autoencoder class
#https://medium.com/pytorch/implementing-an-autoencoder-in-pytorch-19baa22647d1
class AE_class(nn.Module):
    def __init__(self, **kwargs):
        super().__init__()
        self.encoder_hidden_layer = nn.Linear(
            in_features=kwargs["input_shape"], out_features=128
        )
        self.encoder_output_layer = nn.Linear(
            in_features=128, out_features=128
        )
        self.decoder_hidden_layer = nn.Linear(
            in_features=128, out_features=128
        )
        self.decoder_output_layer = nn.Linear(
            in_features=128, out_features=kwargs["input_shape"]
        )

    def forward(self, features):
        #print("in forward")
        #print(type(features))
        activation = self.encoder_hidden_layer(features)
        activation = torch.relu(activation)
        code = self.encoder_output_layer(activation)
        code = torch.relu(code)
        activation = self.decoder_hidden_layer(code)
        activation = torch.relu(activation)
        activation = self.decoder_output_layer(activation)
        reconstructed = torch.relu(activation)
        return reconstructed
    
    def encode(self, features_h):
        activation_h = self.encoder_hidden_layer(features_h)
        activation_h = torch.relu(activation_h)
        code_h = …
Run Code Online (Sandbox Code Playgroud)

python debugging gpu autoencoder pytorch

5
推荐指数
1
解决办法
1万
查看次数

将 Pytorch 的张量元素转换为“float”类型而不是“double”类型

我有一个矩阵保存为 numpy 类型,称之为“X_before”(例如,它的形状是 100*30)。

因为我想使用 Pytorch 库将其提供给 AutoEncoder,所以我将其转换为torch.tensor如下所示:

X_tensor = torch.from_numpy(X_before, dtype=torch)
Run Code Online (Sandbox Code Playgroud)

然后,我收到以下错误:

expected scalar type Float but found Double
Run Code Online (Sandbox Code Playgroud)

接下来,我尝试将元素设置为“float”,然后将它们转换为 torch.tensor:

X_before = X_before.astype(float)
X_tensor = torch.from_numpy(X_before)
Run Code Online (Sandbox Code Playgroud)

同样的错误再次发生。我应该如何解决这个问题?如何将 torch.tensor 对象中的元素类型转换为另一种类型?

提前致谢

arrays casting autoencoder pytorch tensor

4
推荐指数
1
解决办法
7664
查看次数

Numpy 的“shape”函数返回二维数组的一维值

所以我创建了这个数组作为例子:

a = np.array([[1, 1, 1, 1, 2], [2, 2, 2, 3], [3, 3, 3, 4], [13, 49, 13, 49], [10, 10, 2, 2],
             [11, 1, 1, 1, 2], [22, 2, 2, 3], [33, 3, 3, 4], [133, 49, 13, 49], [100, 10, 2, 2],
             [5, 1, 1, 1, 2], [32, 2, 2, 3], [322, 3, 3, 4], [13222, 49, 13, 49], [130, 10, 2, 2]])
Run Code Online (Sandbox Code Playgroud)

我想创建一个二维数组。因此,例如在这种情况下,15*5 数组。

但是,当我使用 时a.shape,它返回(15,)

我的数组定义有什么问题?

python arrays numpy multidimensional-array python-3.x

2
推荐指数
1
解决办法
376
查看次数

SQL查询混淆 - 演员,角色,电影

我有三张桌子:

演员

id 
nameofactor
Run Code Online (Sandbox Code Playgroud)

电影

id
nameOfmovie 
Run Code Online (Sandbox Code Playgroud)

actorid 
movieid
role 
Run Code Online (Sandbox Code Playgroud)

我想展示在电影中扮演多个角色的演员的名字

这是我尝试过的:

select 
    nameOfactor, nameOfmovie, CASTS.role
from 
    ACTOR, MOVIE, CASTS
where 
    ACTOR.id = CASTS.actorid 
    and CASTS.mid = MOVIE.movieid
group by 
    fname, lname, name, role
having 
    count(pid) >= 2; 
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

我想问题就是这样我必须把"角色"放在分组中,但是因为我需要展示角色,所以我不得不这样做

我不知道如何解决这个问题.如果有人能提供帮助,我会很高兴

提前致谢

sql sql-server

0
推荐指数
1
解决办法
180
查看次数