GVKun编程网logo

【DL4J】centos eclipse运行dl4j-examples例子(eclipsejdk)

1

对于【DL4J】centoseclipse运行dl4j-examples例子感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍eclipsejdk,并为您提供关于beta-7上的Dl4J编译错误错

对于【DL4J】centos eclipse运行dl4j-examples例子感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍eclipsejdk,并为您提供关于beta-7 上的 Dl4J 编译错误 错误:、CentOS 6 升级到 CentOS 7、CentOS 6.9 yum 和源码安装 htop,适用于 centOS 7、CentOS 7.0 yum install 错误http://vault.centos.org/centos/7/os/Source/repodata/repomd.xml: [Errno 14]的有用信息。

本文目录一览:

【DL4J】centos eclipse运行dl4j-examples例子(eclipsejdk)

【DL4J】centos eclipse运行dl4j-examples例子(eclipsejdk)

参考https://depiesml.wordpress.com/2015/08/26/dl4j-gettingstarted/
(建议用谷歌浏览器,翻译成中文看)

一、配置java、maven

二、配置eclipse

1、下载eclipsehttp://www.eclipse.org/downloads/
2、配置maven插件
参考https://blog.csdn.net/qq_39209361/article/details/82861674

三、下载dl4j-examples

下载链接:https://github.com/eclipse/deeplearning4j-examples

四、新建maven项目

1、File→New→Other
2、打开Maven文件夹并选择Maven项目
3、单击next直到如图界面,填写组 ID 和工件 ID


4、编辑pom.xml文件
将之前下载的dl4j-examples中的pom.xml文件内容复制到里面



5、maven自动下载依赖
右键单击我们的项目,Maven→Update Project

五、运行例子

把之前下载的dl4j-examples中的某个例子,比如MoonClassifier复制到项目中,点击运行即可。

beta-7 上的 Dl4J 编译错误 错误:

beta-7 上的 Dl4J 编译错误 错误:

如何解决beta-7 上的 Dl4J 编译错误 错误:

尝试在 Dl4J (java) 中构建 MultiLayerConfiguration 时遇到一些编译器错误。根据 GitHub 存储库的文档和示例,它们很好。

我使用的是 NetBeans IDE,带有 Dl4J 1.0.0 beta-7。我的 JDK 设置为 11。当我在 beta-6 上有完全相同的代码时,没有问题,但在 beta-7 上似乎没有任何办法来解决这些错误。

这个项目(虹膜分类器)只是 Dl4J GitHub 示例存储库中的项目之一,它不能与 Dl4J 1.0.0-beta-7 一起工作。它抱怨上面列出的事情。

//...
import org.datavec.api.records.reader.RecordReader;
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
import org.datavec.api.split.FileSplit;
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.OutputLayer;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.nn.weights.Weightinit;
import org.deeplearning4j.optimize.listeners.scoreIterationListener;
import org.deeplearning4j.examples.utils.DownloaderUtility;
import org.nd4j.evaluation.classification.Evaluation;
import org.nd4j.linalg.activations.Activation;
import org.nd4j.linalg.api.ndarray.Indarray;
import org.nd4j.linalg.dataset.DataSet;
import org.nd4j.linalg.dataset.SplitTestAndTrain;
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
import org.nd4j.linalg.dataset.api.preprocessor.Datanormalization;
import org.nd4j.linalg.dataset.api.preprocessor.normalizerStandardize;
import org.nd4j.linalg.learning.config.Sgd;
import org.nd4j.linalg.lossfunctions.LossFunctions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * @author Adam Gibson
 */
@SuppressWarnings("DuplicatedCode")
public class IrisClassifier {

    private static Logger log = LoggerFactory.getLogger(IrisClassifier.class);

    public static void main(String[] args) throws  Exception {

        //First: get the dataset using the record reader. CSVRecordReader handles loading/parsing
        int numLinesToSkip = 0;
        char delimiter = '','';
        RecordReader recordReader = new CSVRecordReader(numLinesToSkip,delimiter);
        recordReader.initialize(new FileSplit(new File(DownloaderUtility.IRISDATA.Download(),"iris.txt")));

        //Second: the RecordReaderDataSetIterator handles conversion to DataSet objects,ready for use in neural network
        int labelIndex = 4;     //5 values in each row of the iris.txt CSV: 4 input features followed by an integer label (class) index. Labels are the 5th value (index 4) in each row
        int numClasses = 3;     //3 classes (types of iris flowers) in the iris data set. Classes have integer values 0,1 or 2
        int batchSize = 150;    //Iris data set: 150 examples total. We are loading all of them into one DataSet (not recommended for large data sets)

        DataSetIterator iterator = new RecordReaderDataSetIterator(recordReader,batchSize,labelIndex,numClasses);
        DataSet allData = iterator.next();
        allData.shuffle();
        SplitTestAndTrain testAndTrain = allData.splitTestAndTrain(0.65);  //Use 65% of data for training

        DataSet trainingData = testAndTrain.getTrain();
        DataSet testData = testAndTrain.gettest();

        //We need to normalize our data. We''ll use normalizeStandardize (which gives us mean 0,unit variance):
        Datanormalization normalizer = new normalizerStandardize();
        normalizer.fit(trainingData);           //Collect the statistics (mean/stdev) from the training data. This does not modify the input data
        normalizer.transform(trainingData);     //Apply normalization to the training data
        normalizer.transform(testData);         //Apply normalization to the test data. This is using statistics calculated from the *training* set


        final int numInputs = 4;
        int outputNum = 3;
        long seed = 6;


        log.info("Build model....");
        MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
            .seed(seed)
            .activation(Activation.TANH)
            .weightinit(Weightinit.XAVIER)
            .updater(new Sgd(0.1))
            .l2(1e-4)
            .list()
/*FAIL >*/  .layer(new DenseLayer.Builder().nIn(numInputs).nOut(3)
                .build())
            .layer(new DenseLayer.Builder().nIn(3).nOut(3)
                .build())
            .layer( new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
                .activation(Activation.softmax) //Override the global TANH activation with softmax for this layer
                .nIn(3).nOut(outputNum).build())
            .build();

        //run the model
        MultiLayerNetwork model = new MultiLayerNetwork(conf);
        model.init();
        //record score once every 100 iterations
        model.setListeners(new scoreIterationListener(100));

        for(int i=0; i<1000; i++ ) {
            model.fit(trainingData);
        }

        //evaluate the model on the test set
        Evaluation eval = new Evaluation(3);
        Indarray output = model.output(testData.getFeatures());
        eval.eval(testData.getLabels(),output);
        log.info(eval.stats());

    }

}

错误:

COMPILATION ERROR : 
-------------------------------------------------------------
com/dl4jtest/csv/IrisClassifier.java:[("FAIL" marker),17] method layer in class org.deeplearning4j.nn.conf.NeuralNetConfiguration.ListBuilder cannot be applied to given types;
  required: int,org.deeplearning4j.nn.conf.layers.Layer
  found: org.deeplearning4j.nn.conf.layers.DenseLayer
  reason: actual and formal argument lists differ in length

https://github.com/eclipse/deeplearning4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/quickstart/modeling/feedforward/classification/IrisClassifier.java

CentOS 6 升级到 CentOS 7

CentOS 6 升级到 CentOS 7

注意

非必要情况,请使用重新安装系统的方式升级,原因如下:

  1. 并非所有的系统都能顺利从 6 升级到 7,安装的软件越少,升级成功的可能性越大;
  2. 只支持 6.5 及以上系统升级到不高于 7.2 系统;
  3. 升级的耗时完全不比重新安装少,绝大多数情况下会耗费更长的时间和更多精力;
  4. 升级完成后处理各种依赖是一个非常头大的问题。

本人在同一天升级了两台电脑,一个成功一个失败。成功的那台电脑额外花了一天时间处理各种依赖和问题,失败的电脑半小时装好系统和必备软件,用得爽歪歪。所以如非必要,建议采用备份数据后直接重装系统的方式。

操作

通过软件方式从 6 升级到 7,请参考下面的步骤:

  1. 升级当前系统到最新版本:yum update -y

  2. 安装旧版 openscap: yum remove -y openscap && yum install -y http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm

  3. 添加 upgradetool 源:

    cat <<EOF >/etc/yum.repos.d/upgradetool.repo
    [upgrade]
    name=CentOS-$releasever - Upgrade Tool
    baseurl=http://dev.centos.org/centos/6/upg/x86_64/
    gpgcheck=1
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    EOF
    
  4. 安装升级工具:yum install -y redhat-upgrade-tool preupgrade-assistant preupgrade-assistant-contents

  5. 执行升级可行性分析:preupg -l,该命令会耗费几分钟到几十分钟时间。如果出现 preupg: error: [Errno 2] No such file or directory: ''/root/preupgrade/result.html'' 的错误,请参考第一步安装 openscap 的旧版;

  6. 使用清华大学的 centos-vault 源安装 7.2 版本:centos-upgrade-tool-cli --network 7 --instrepo=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.2.1511/os/x86_64/

    ** 注意:**7.2 是支持升级的最高版本,升级其他版本将会出现 Downloading failed: invalid data in .treeinfo: No section: ''checksums'' 的错误提示;

  7. 如果升级成功,用 reboot 命令重启系统;如果提示 The requested URL returned error: 404 Not Found 等错误,基本上说明当前系统不支持直接升级。果断采用重装系统的正道吧,少年!

  8. 系统重启后,有可能因为依赖库确实导致 ssh 无法启动,grep 不能正常使用等问题。基本功底够好的手动排查,然后一个个问题解决;搞不懂错误原因或者觉得处理麻烦的,备份数据后重装系统吧!

  9. 使用 rpm -qa | grep el6 查看系统上残留的软件包。如果能手动清理掉,让系统 update 无障碍,耐心一个个处理掉。如果觉得依赖太麻烦或者搞不定,备份数据后重装系统吧!

参考

  1. https://blog.51cto.com/moerjinrong/2340656

CentOS 6.9 yum 和源码安装 htop,适用于 centOS 7

CentOS 6.9 yum 和源码安装 htop,适用于 centOS 7

CentOS6.9 安装 htop,也适用于 CentOS7。htop 官方网站:http://hisham.hm/htop/ 。

首先安装首先启用 epel repository。

[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum -y update
#安装htop
[root@localhost ~]# yum install htop

yum 安装 htop 完成。

也可以配置阿里云、清华大学等安装源。清华大学链接。

https://mirrors.tuna.tsinghua.edu.cn/help/epel/

源码安装 htop,首先安装 git。ncurses-devel 编译安装 htop 时需要。

[root@localhost ~]# yum -y install git ncurses-devel

htop GIT 源码下载地址。https://github.com/hishamhm/htop

git clone htop 代码。

[root@localhost ~]# git clone https://github.com/hishamhm/htop.git

切换到 htop 代码目录执行./configure; make; sudo make install 即可。

下图是 centOS6.9 安装完成软件运行截图。

CentOS 7.0 yum install 错误http://vault.centos.org/centos/7/os/Source/repodata/repomd.xml: [Errno 14]

CentOS 7.0 yum install 错误http://vault.centos.org/centos/7/os/Source/repodata/repomd.xml: [Errno 14]

执行yum install vconfig时老是报错:

http://vault.centos.org/centos/7/os/Source/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

经过分析:

原因是标准的CentOS 7.0 Build1406里面很多的仓库已经被CentOS移除了,转到CentOS 7.1 Build1503和CentOS7.2 Build1503了。

因此需要手工更改仓库文件/etc/yum.d.repo/CentOS-Sources.repo,

更改之前,先备份下

#cp CentOS-Sources.repo CentOS-Sources.repo.bak

然后开始编辑CentOS-Sources.repo文件。

将文件中的“$releasever”全部替换成“7.2.1511”或者“7.1.1503”。

[base-source]
name=CentOS-7.2.1511 - Base Sources
baseurl=http://vault.centos.org/centos/7.2.1511/os/Source/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates-source]
name=CentOS-7.2.1511 - Updates Sources
baseurl=http://vault.centos.org/centos/7.2.1511/updates/Source/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras-source]
name=CentOS-7.2.1511 - Extras Sources
baseurl=http://vault.centos.org/centos/7.2.1511/extras/Source/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus-source]
name=CentOS-7.2.1511 - Plus Sources
baseurl=http://vault.centos.org/centos/7.2.1511/centosplus/Source/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

更改完成后执行

#yum clean

#yum update

今天关于【DL4J】centos eclipse运行dl4j-examples例子eclipsejdk的介绍到此结束,谢谢您的阅读,有关beta-7 上的 Dl4J 编译错误 错误:、CentOS 6 升级到 CentOS 7、CentOS 6.9 yum 和源码安装 htop,适用于 centOS 7、CentOS 7.0 yum install 错误http://vault.centos.org/centos/7/os/Source/repodata/repomd.xml: [Errno 14]等更多相关知识的信息可以在本站进行查询。

本文标签: