小编Whi*_*hot的帖子

将展开的 GAN 更新为 TF2

我正在尝试使用示例代码实现此处描述的 Unrolled GAN 模型。但是,它是使用 TF1 实现的,我一直在尽最大努力对其进行更新,但我对 python 和 TF 相对较新(过去仅使用了约 6 个月)。

我似乎无法完成的行(目前,可能还有更多)是这样的:

gen_vars = tf.compat.v1.get_collection(tf.compat.v1.GraphKeys.TRAINABLE_VARIABLES, "generator")
disc_vars = tf.compat.v1.get_collection(tf.compat.v1.GraphKeys.TRAINABLE_VARIABLES, "discriminator")
Run Code Online (Sandbox Code Playgroud)

这些都返回空列表,我看不到我错过了什么。即使没有指定范围,也会get_collection()返回[]. 早些时候,我们将生成器和鉴别器都定义为范围,如下所示:

def generator(z, output_dim=2, n_hidden=128, n_layer=2):
    with tf.compat.v1.variable_scope("generator"):
        h = slim.stack(z, slim.fully_connected, [n_hidden] * n_layer, activation_fn=tf.nn.tanh)
        x = slim.fully_connected(h, output_dim, activation_fn=None)
    return x

def discriminator(x, n_hidden=128, n_layer=2, reuse=False):
    with tf.compat.v1.variable_scope("discriminator", reuse=reuse):
        h = slim.stack(x, slim.fully_connected, [n_hidden] * n_layer, activation_fn=tf.nn.tanh)
        log_d = slim.fully_connected(h, 1, activation_fn=None)
    return log_d
Run Code Online (Sandbox Code Playgroud)

范围的定义有问题吗?

这是我更新的完整代码,以防万一我在其他地方遗漏了一些东西:

%pylab inline …
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow generative-adversarial-network

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

如何在文本文件中查找和删除表情符号?

我正在尝试从我主要使用 sed 和一些 perl 命令解析的文本文件中删除所有表情符号,并且最好将它们存储在一个单独的文件中,但这不是必需的。

我可以用 bash 或 perl 轻松做到这一点吗?还是我应该使用另一种语言?

编辑:感谢 Cyrus 和 Barmar 为我指出正确的方向,解决这个问题。但是,它没有告诉我如何仅从文本文件中删除表情符号。他们使用 bash 行:

grep -P "[\x{1f300}-\x{1f5ff}\x{1f900}-\x{1f9ff}\x{1f600}-\x{1f64f}\x{1f680}-\x{1f6ff}\x{2600}-\x{26ff}\x{2700}-\x{27bf}\x{1f1e6}-\x{1f1ff}\x{1f191}-\x{1f251}\x{1f004}\x{1f0cf}\x{1f170}-\x{1f171}\x{1f17e}-\x{1f17f}\x{1f18e}\x{3030}\x{2b50}\x{2b55}\x{2934}-\x{2935}\x{2b05}-\x{2b07}\x{2b1b}-\x{2b1c}\x{3297}\x{3299}\x{303d}\x{00a9}\x{00ae}\x{2122}\x{23f3}\x{24c2}\x{23e9}-\x{23ef}\x{25b6}\x{23f8}-\x{23fa}]"  myflie.txt | more
Run Code Online (Sandbox Code Playgroud)

这让我得到了包含表情符号的所有

grep -Pv 将从输入中删除这些行,

grep -Po 将只返回表情符号,

grep -Pov 什么都不返回。

有谁知道如何从文本中删除这些特定字符?

注意:我知道这个问题,但我的文本文件根本没有格式化。表情符号与文本的其余部分混合在一起。

emoji

3
推荐指数
1
解决办法
1566
查看次数

更改由函数创建的 ggplot 对象的颜色

我正在使用该fgsea库进行一些分析,特别是我经常使用该plotEnrichment函数。此函数返回一个包含所有图层的 ggplot 对象,但我想将它显示的曲线从明亮更改为其他内容。这段代码

library(fgsea)
data(examplePathways)
data(exampleRanks)
p = plotEnrichment(examplePathways[["5991130_Programmed_Cell_Death"]], exampleRanks)
Run Code Online (Sandbox Code Playgroud)

将返回这个情节 Basic fgsea plotEnrichment plot

有没有办法在创建后改变颜色?

注意:我很确定有很多方法可以很容易地做到这一点,但我没有创建情节,所以我不知道每个图层的名称或它们是如何创建的。


根据 BrianFisher 的建议,我尝试了

p + scale_color_brewer(palette="GnBu")
p + scale_color_manual(values=c("blue","red"))
Run Code Online (Sandbox Code Playgroud)

但据我所知,他们并没有改变情节的任何内容。

r ggplot2

3
推荐指数
1
解决办法
389
查看次数

在 WSL2 上运行的 Jupyter 实验室网络错误

我在 WSL2 Ubuntu 上运行 Jupyter Lab,并在 Win10 PC 上的 Firefox 中访问它。它们在同一台机器上运行,因此不应该涉及“网络”。我将其运行为jupyter lab --no-browser. 服务器在终端中启动得很好:

[I 11:17:40.843 LabApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 11:17:40.885 LabApp] JupyterLab extension loaded from /home/muthur/anaconda3/lib/python3.8/site-packages/jupyterlab  
[I 11:17:40.886 LabApp] JupyterLab application directory is /home/muthur/anaconda3/share/jupyter/lab                    
[I 11:17:40.888 LabApp] Serving notebooks from local directory: /home/muthur                                            
[I 11:17:40.888 LabApp] Jupyter Notebook 6.2.0 is running at:                                                           
[I 11:17:40.888 LabApp] http://localhost:8888/?token=...                                                                
[I 11:17:40.888 LabApp]  or http://127.0.0.1:8888/?token=...                                                            
[I 11:17:40.888 LabApp] Use Control-C to stop this server and shut down all kernels (twice …
Run Code Online (Sandbox Code Playgroud)

jupyter-notebook windows-subsystem-for-linux wsl-2

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