我将一个csv文件加载到“数据集”中,并尝试执行dataset.head(),但它报告了一个错误。如何检查numpy数组的头或尾?没有指定特定的行?
我在Eclipse中调试Hashtable并发现了一些奇怪的东西.我的Hashtable变量名是"my_hashTable",而Eclipse调试器,如果我点击它,它显示它的值是三:{first = 0,third = 2,second = 1},这是正确的,并且计数是3 ,这也是正确的.
但是,如果我单击my_hashTable变量中的"table"变量,它会显示只有两个非空值,[4] = 2和[5] = 0.其完整值如下:
[null,null,null,null,third = 2,first = 0,null]
为什么会这样?"second = 1"对在哪里?这是我第一次在Eclipse中遇到这种奇怪的观察.
知道发生了什么事吗?谢谢.
我是按照 sonatype 的书中给出的示例来学习 Maven 的新手。这是一个最简单的pom.xml文件(工作正常)。但我的问题是,maven (mvn install) 如何找到我的机器上安装的 Java 编译器 (javac)?该 POM 文件不以任何方式指定 JDK。谢谢你的解释。
编辑:
作为比较,我按照书中的下一个示例进行操作,这一次,我收到编译错误,因为它找不到 javax。我的 java 文件位于其中,如书中建议的那样:src/main/java/org/sonatype/mavenbook/web/SimpleServlet.java
现在,当我运行 mvncompile 时,我收到下面的错误消息。为什么现在maven找不到编译器:
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project simple-webapp: Compilation failure: Compilation failure:
[ERROR] /home/abigail/study/simple-webapp/src/main/java/org/sonatype/mavenbook/web/SimpleServlet.java:[4,1] package javax.servlet does not exist
Run Code Online (Sandbox Code Playgroud)
POM.xml
<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
http://maven.apache.org/maven- v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook.simpleweb</groupId>
<artifactId>simple-webapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>simple-webapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin> …Run Code Online (Sandbox Code Playgroud) 在定义父工件时,我是否需要将其包含在子项的pom中?例如,
是<relativePath>可选的还是必需的?
<parent>
<groupId>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorials</artifactId>
<version>5.1.0.Final</version>
<relativePath>../pom.xml</relativePath>
</parent>
Run Code Online (Sandbox Code Playgroud) def get_train_dataset(file_path, **kwargs):
dataset = tf.data.experimental.make_csv_dataset(
file_path,
batch_size=5,
label_name=LABEL_COLUMN,
na_value="?",
num_epochs=1,
ignore_errors=True,
**kwargs)
return dataset
raw_train_data = get_train_dataset(train_file_path, select_columns=CSV_COLUMNS)
Run Code Online (Sandbox Code Playgroud)
我从“make_csv_dataset”函数创建了一个数据集,它是 OrderDict 的 PrefectDataset。但是,当我拟合模型时:
embedding = "https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1"
hub_layer = hub.KerasLayer(embedding, input_shape=[],
dtype=tf.string, trainable=True)
model = tf.keras.Sequential()
model.add(hub_layer)
model.add(tf.keras.layers.Dense(16, activation='relu'))
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
history = model.fit(train_data.shuffle(10000),
epochs=20,
validation_data=val_data,
verbose=1)
Run Code Online (Sandbox Code Playgroud)
它报告一个错误:
File "/home/my-env/tf/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py", line 118, in <listcomp>
inputs = [inputs[key] for key in model._feed_input_names]
KeyError: 'keras_layer_input'
Run Code Online (Sandbox Code Playgroud)
我希望将此 OrderedDictionary 转换为 TF.Tensor,然后“fit”方法应该可以工作。怎么做?或者还有其他方法可以解决这个问题吗?
在另一篇文章中,我看到:
The not very elegant workaround you can try is to …Run Code Online (Sandbox Code Playgroud) 我的代码在 iPython 终端中运行时运行良好,但由于内存不足错误而失败,如下所示。
/home/abigail/anaconda3/envs/tf_gpuenv/bin/python -Xms1280m -Xmx4g /home/abigail/PycharmProjects/MLNN/src/test.py
Using TensorFlow backend.
Epoch 1/150
2019-01-19 22:12:39.539156: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-01-19 22:12:39.588899: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-01-19 22:12:39.589541: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce GTX 750 Ti major: 5 minor: 0 …Run Code Online (Sandbox Code Playgroud) 我通常使用“不是无”来测试对象是否为空。我看到代码只使用'if object'。它们是一样的吗?
例如,
if Dog:
...
Run Code Online (Sandbox Code Playgroud)
VS
if Dog is not None:
...
Run Code Online (Sandbox Code Playgroud) s = '?? ?'
print(len(s))
s = s.strip()
print(len(s))
Run Code Online (Sandbox Code Playgroud)
两者的输出都是“4”。似乎空格占用了 2 个字符,并且无法通过 strip() 函数删除。这是一个中文空格,不能被strip函数删除。