我对keras的conv1d层中的这两个参数感到非常困惑:https://keras.io/layers/convolutional/#conv1d
文件说:
filters: Integer, the dimensionality of the output space (i.e. the number output of filters in the convolution).
kernel_size: An integer or tuple/list of a single integer, specifying the length of the 1D convolution window.
Run Code Online (Sandbox Code Playgroud)
但是,这似乎并没有涉及到的标准术语我在很多教程看到诸如https://adeshpande3.github.io/adeshpande3.github.io/A-Beginner的-引导到理解,卷积Neural- Networks /和https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/
使用第二个使用Keras的教程链接,我想实际上'kernel_size'与传统的'filter'概念相关,后者定义了输入特征空间上的滑动窗口.但是conv1d中的'filter'参数怎么样?它有什么作用?
例如,在以下代码段中:
model.add(embedding_layer)
model.add(Dropout(0.2))
model.add(Conv1D(filters=100, kernel_size=4, padding='same', activation='relu'))
Run Code Online (Sandbox Code Playgroud)
假设嵌入层输出一个维度为50的矩阵(行,每行是一个句子中的一个单词)x 300(列,单词向量维度),conv1d层如何转换该矩阵?
非常感谢
我注意到从solr 5.3更改为6.1后,我创建EmbeddedSolrServer的代码(见下文)将导致以下异常:
String solrHome = prop.getProperty(PROPERTY_FIELD_SOLR_HOME);
String solrCore = "anotherCore";
CoreContainer solrCores = new EmbeddedSolrServer(
Paths.get(solrHome), solrCore
).getCoreContainer();
EmbeddedSolrServer mycore=
new EmbeddedSolrServer(solrCores.getCore("mycore"));
Run Code Online (Sandbox Code Playgroud)
最后一行适用于solr 5.3,但是使用6.1时,会生成以下异常.有什么想法吗?
Exception in thread "main" org.apache.solr.common.SolrException: SolrCore 'mycore' is not available due to init failure: Error loading class 'solr.admin.AdminHandlers'
at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:1066)
at uk.ac.ntu.sac.sense.SenseProperty.getClassIndex(SenseProperty.java:91)
at uk.ac.ntu.sac.sense.kb.indexer.IndexMaster.<init>(IndexMaster.java:31)
at uk.ac.ntu.sac.sense.test.TestIndexer.main(TestIndexer.java:14)
Caused by: org.apache.solr.common.SolrException: Error loading class 'solr.admin.AdminHandlers'
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:773)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:647)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:812)
at org.apache.solr.core.CoreContainer.lambda$load$0(CoreContainer.java:466)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$22(ExecutorUtil.java:229)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.solr.common.SolrException: Error loading …
Run Code Online (Sandbox Code Playgroud) 据我所知,train_test_split方法将数据集拆分为随机序列和测试子集.并且使用random_state = int可以确保每次调用方法时我们在此数据集上都有相同的拆分.
我的问题略有不同.
我有两个数据集,A和B,它们包含相同的示例集,每个数据集中出现的这些示例的顺序也相同.但它们的关键区别在于每个数据集中的exmaples使用不同的功能集.
我想测试一下A中使用的功能是否比B中使用的功能更好.所以我想确保当我在A和B上调用train_test_split时,我可以在两个数据集上获得相同的分割,以便比较是有意义的.
这可能吗?我是否只需要确保两个数据集的两个方法调用中的random_state都相同?
谢谢
我知道这似乎已经讨论过,答案是肯定的,String.hashCode
可以为不同的字符串生成相同的值,但是不太可能(Java的hashCode可以为不同的字符串生成相同的值吗?).但它确实发生在我的应用程序中.
以下代码将生成相同的哈希码:-347019262(jave 1.7.25)
String string1 = "/m/06qw_";
String string2="/m/0859_";
System.out.println(string1+","+string1.hashCode());
System.out.println(string2+","+string2.hashCode());
Run Code Online (Sandbox Code Playgroud)
在这种情况下我确实需要哈希码,我想用它来为字符串生成唯一的主键.看来我做得不对.有什么建议吗?
非常感谢!
我已经成功安装了 CUDA 驱动程序、cuDNN 库和张量流。但是,当运行仅导入tensorflow的测试程序时,我收到错误。该错误似乎表明我安装了错误版本的 cuDNN 库。我希望得到一些帮助。如果我需要降级 cuDNN,我该怎么做?
Tensorflow 版本:2.2 GPU 操作系统:Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-184-generic x86_64) nvcc -V 显示以下信息:
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17
Run Code Online (Sandbox Code Playgroud)
nvidia-smi 显示以下信息:
Fri Jun 12 17:16:38 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.36.06 Driver Version: 450.36.06 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute …
Run Code Online (Sandbox Code Playgroud) 我在R3.0.1上安装rJava时遇到了这个问题:"configure:error:一个或多个JNI类型与相应的本机类型不同"
详细信息见下文.我搜索了类似的问题,但我的问题有点棘手,许多提议的解决方案要么无法工作,要么我无法尝试,因为我正在服务器上,我没有对系统库的写访问权.
操作系统:Linux 2.6.18-348.6.1.el5#1 SMP Tue 5月21日15:44:27 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux(通过输入"uname -a"给出的信息抱歉我不太明白这个信息)
R:R3.0.1,我下载了源代码,放入我的主目录,并从源代码构建了R.
rJava:我在安装过程中运行了'install.packages("rJava")':
=========================
检查R中的Java支持...现在:
解释器:'/ usr/bin /
java'archiver:'/ usr/bin/jar'
编译器:'/ usr/bin/javac'
标题准备:'/ usr/bin/javah'cpp
flags:' - I/usr/lib/jvm/java-1.7.0-openjdk-1.7. 0.9.x86_64/jre /../ include -
I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre /../ include/linux'java
libs:' - L/usr /lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/lib/amd64/se
rver -ljvm'
检查是否可以编译JNI程序...是
检查JNI数据类型... configure:错误:一个或多个JNI类型与
相应的本机类型不同.您可能需要使用非标准编译器标志或
不同的编译器来解决此问题.
错误:包'rJava'
*删除'/home/me/R-3.0.1/library/rJava'的配置失败
==================================
由于我只能远程访问服务器,因此我无法对主目录/ home/me以外的任何内容进行写访问.
任何信息都将受到高度赞赏!
我正在使用Keras创建ANN并在网络上进行网格搜索.运行以下代码时遇到以下错误:
model = KerasClassifier(build_fn=create_model(input_dim), verbose=0)
# define the grid search parameters
batch_size = [10, 20]
epochs = [50, 100]
dropout = [0.3, 0.5, 0.7]
param_grid = dict(dropout_rate=dropout, batch_size=batch_size, nb_epoch=epochs)
pipe.append(('classify', model))
params.append(param_grid)
pipeline=Pipeline(pipe)
#the pipeline also contains feature selector, but for convenience I do not include code here
piped_classifier = GridSearchCV(estimator=pipeline, param_grid=params, n_jobs=-1,
cv=nfold)
piped_classifier.fit(X_train, y_train) #this is line 246 of classifier_gridsearch.py causing error, see below,
def create_model(input_dim,dropout_rate=0.0):
# create model
model = Sequential()
model.add(Dense(80,
input_dim=input_dim,
kernel_initializer='uniform', activation='relu'))
model.add(Dropout(dropout_rate))
model.add(Dense(1, …
Run Code Online (Sandbox Code Playgroud) 更新:我必须重新编写这个问题,因为经过一些调查,我意识到这是一个不同的问题。
上下文:使用带有 scikit learn 的 kerasclassifier 包装器在 gridsearch 设置中运行 keras。系统:Ubuntu 16.04,库:anaconda 发行版 5.1、keras 2.0.9、scikitlearn 0.19.1、tensorflow 1.3.0 或 theano 0.9.0,仅使用 CPU。
代码: 我只是使用这里的代码进行测试:https : //machinelearningmastery.com/use-keras-deep-learning-models-scikit-learn-python/,第二个示例“网格搜索深度学习模型参数”。请注意第 35 行,内容如下:
grid = GridSearchCV(estimator=model, param_grid=param_grid)
Run Code Online (Sandbox Code Playgroud)
症状:当网格搜索使用超过 1个作业时(是指 cpus?),例如,将上面 A 行上的“n_jobs”设置为“2”,下面一行:
grid = GridSearchCV(estimator=model, param_grid=param_grid, n_jobs=2)
Run Code Online (Sandbox Code Playgroud)
将导致代码无限期挂起,无论是使用 tensorflow 还是 theano,并且没有 cpu 使用(请参见附加的屏幕截图,其中创建了 5 个 python 进程,但没有一个正在使用 cpu)。
通过调试,似乎是以下带有“sklearn.model_selection._search”的行导致了问题:
line 648: for parameters, (train, test) in product(candidate_params,
cv.split(X, y, groups)))
Run Code Online (Sandbox Code Playgroud)
,程序挂起无法继续。
我真的很感激一些关于这意味着什么以及为什么会发生这种情况的见解。
提前致谢
我正在使用 Keras 函数式 API 创建一个神经网络,该网络将词嵌入层作为句子分类任务的输入。但是我的代码在连接输入层和嵌入层的开始就中断了。按照https://medium.com/tensorflow/predicting-the-price-of-wine-with-the-keras-functional-api-and-tensorflow-a95d1c2c1b03 上的教程,我有如下代码:
max_seq_length=100 #i.e., sentence has a max of 100 words
word_weight_matrix = ... #this has a shape of 9825, 300, i.e., the vocabulary has 9825 words and each is a 300 dimension vector
deep_inputs = Input(shape=(max_seq_length,))
embedding = Embedding(9825, 300, input_length=max_seq_length,
weights=word_weight_matrix, trainable=False)(deep_inputs) # line A
hidden = Dense(targets, activation="softmax")(embedding)
model = Model(inputs=deep_inputs, outputs=hidden)
Run Code Online (Sandbox Code Playgroud)
然后行 A 导致错误,如下所示:
ValueError: You called `set_weights(weights)` on layer "embedding_1" with a weight list of length 9825, but the …
Run Code Online (Sandbox Code Playgroud) I have searched for this and found answers that do not work in my case. I would appreciate some thoughts on this
- However, many users say it works ok for them.
I have found some sources say that this only happens if your link contains 'https' instead of 'http', but tested …
keras ×4
java ×2
python ×2
scikit-learn ×2
tensorflow ×2
convolution ×1
cudnn ×1
github ×1
hashcode ×1
neuraxle ×1
primary-key ×1
r ×1
rjava ×1
solr ×1
string ×1
theano ×1