问题描述
这是文件:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>neural</artifactId>
<dependencies>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>1.0.0-beta7</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-beta7</version>
</dependency>
</dependencies>
</project>
我正在尝试添加deeplearning4j
我得到的错误是(我在IntelliJ中工作)
<project" has a red underline saying "For artifact {org.example:neural:null:jar}: The version cannot be empty.
<artifactId>nd4j-native-platform</artifactId> <version>1.0.0-beta7</version>" is red,saying "Dependency 'org.nd4j:nd4j-native-platform:1.0.0-beta7' not found
感谢您的帮助。
解决方法
我建议使用intellij的Maven原型并自定义该模板或模板项目: https://github.com/eclipse/deeplearning4j-examples/tree/master/mvn-project-template 我知道在stackoverflow上不允许只有链接的答案,所以我总结一下:
?xml version="1.0" encoding="UTF-8"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright (c) 2020 Konduit K.K.
~ Copyright (c) 2015-2019 Skymind,Inc.
~
~ This program and the accompanying materials are made available under the
~ terms of the Apache License,Version 2.0 which is available at
~ https://www.apache.org/licenses/LICENSE-2.0.
~
~ Unless required by applicable law or agreed to in writing,software
~ distributed under the License is distributed on an "AS IS" BASIS,WITHOUT
~ WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. See the
~ License for the specific language governing permissions and limitations
~ under the License.
~
~ SPDX-License-Identifier: Apache-2.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Group-ID,artifact ID and version of the project. You can modify these as you want -->
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-example-sample</artifactId>
<version>1.0.0-beta7</version>
<!-- Properties Section. Change ND4J versions here,if required -->
<properties>
<dl4j-master.version>1.0.0-beta7</dl4j-master.version>
<logback.version>1.2.3</logback.version>
<java.version>1.8</java.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
</properties>
<dependencies>
<!-- deeplearning4j-core: contains main functionality and neural networks -->
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<!--
ND4J backend: every project needs one of these. The backend defines the hardware on which network training
will occur. "nd4j-native-platform" is for CPUs only (for running on all operating systems).
-->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<!-- CUDA: to use GPU for training (CUDA) instead of CPU,uncomment this,and remove nd4j-native-platform -->
<!-- Requires CUDA to be installed to use. Change the version (8.0,9.0,9.1) to change the CUDA version -->
<!--
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-9.2-platform</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
-->
<!-- Optional,but recommended: if you use CUDA,also use CuDNN. To use this,CuDNN must also be installed -->
<!-- See: https://deeplearning4j.konduit.ai/config/backends/config-cudnn#using-deeplearning-4-j-with-cudnn -->
<!--
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-cuda-9.2</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven compiler plugin: compile for Java 8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<!--
Maven shade plugin configuration: this is required so that if you build a single JAR file (an "uber-jar")
it will contain all the required native libraries,and the backends will work correctly.
Used for example when running the following commants
mvn package
cd target
java -cp deeplearning4j-examples-1.0.0-beta-bin.jar org.deeplearning4j.LenetMnistExample
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>bin</shadedClassifierName>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>org/datanucleus/**</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
您可以使用dl4j快速入门来告诉您更多信息。实际上,您应该尝试从现有项目开始,并尽可能导入为Maven项目。如果不是,请在intellij中创建一个原型原型的新Maven项目并对其进行自定义。通常我们使用Java快速入门。
,您没有pom.xml的版本
更改此:
<groupId>org.example</groupId>
<artifactId>neural</artifactId>
对此:
<groupId>org.example</groupId>
<artifactId>neural</artifactId>
<version>1.0.0</version>