0

为什么我收到错误

java.lang.NoClassDefFoundError: org/nd4j/linalg/api/ops/impl/transforms/floating/Histogram

在尝试设置侦听gan.setListeners(new StatsListener(statsStorage));器时

像这样的 GAN 网络(来自https://github.com/wmeddie/dl4j-gans的示例代码):

generator = generatorSupplier.get();
        generator.init();

        Layer[] genLayers = generator.getLayers();
        int numGenLayers = genLayers.length;

        discriminator = discriminatorSupplier.provide(updater);
        discriminator.init();

        MultiLayerNetwork ganDiscriminator = discriminatorSupplier.provide(UPDATER_ZERO);
        ganDiscriminator.init();

        Layer[] disLayers = ganDiscriminator.getLayers();
        Layer[] layers = ArrayUtils.addAll(genLayers, disLayers);
        MultiLayerConfiguration genConf = generator.getLayerWiseConfigurations();
        MultiLayerConfiguration disConf = ganDiscriminator.getLayerWiseConfigurations();
        org.deeplearning4j.nn.conf.layers.Layer[] confLayers = new org.deeplearning4j.nn.conf.layers.Layer[layers.length];

        Map<Integer, InputPreProcessor> preProcessors = new HashMap<>();
        for (int i = 0; i < layers.length; i++) {
            confLayers[i] = layers[i].conf().getLayer();
            if (i < numGenLayers) {
                preProcessors.put(i, genConf.getInputPreProcess(i));
            } else {
                preProcessors.put(i, disConf.getInputPreProcess(i - numGenLayers));
            }
        }

        MultiLayerConfiguration ganConf = new NeuralNetConfiguration.Builder()
                .seed(seed)
                .updater(updater)
                .biasUpdater(biasUpdater)
                .optimizationAlgo(optimizer)
                .gradientNormalization(gradientNormalizer)
                .gradientNormalizationThreshold(gradientNormalizationThreshold)
                .activation(Activation.IDENTITY)
                .trainingWorkspaceMode(trainingWorkSpaceMode)
                .inferenceWorkspaceMode(inferenceWorkspaceMode)
                .cacheMode(cacheMode)
                .list(confLayers)
                .inputPreProcessors(preProcessors)
                .build();
        gan = new MultiLayerNetwork(ganConf);
        gan.init();

Exception in thread "main" java.lang.NoClassDefFoundError: org/nd4j/linalg/api/ops/impl/transforms/floating/Histogram
    at org.deeplearning4j.ui.stats.BaseStatsListener.getHistograms(BaseStatsListener.java:766)
    at org.deeplearning4j.ui.stats.BaseStatsListener.onForwardPass(BaseStatsListener.java:267)
    at org.deeplearning4j.ui.stats.BaseStatsListener.onForwardPass(BaseStatsListener.java:257)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.computeGradientAndScore(MultiLayerNetwork.java:2633)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.computeGradientAndScore(MultiLayerNetwork.java:2587)
    at org.deeplearning4j.optimize.solvers.BaseOptimizer.gradientAndScore(BaseOptimizer.java:160)
    at org.deeplearning4j.optimize.solvers.StochasticGradientDescent.optimize(StochasticGradientDescent.java:63)
    at org.deeplearning4j.optimize.Solver.optimize(Solver.java:52)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.fitHelper(MultiLayerNetwork.java:2169)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.fit(MultiLayerNetwork.java:2126)
    at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.fit(MultiLayerNetwork.java:2194)
    at io.skymind.example.GAN.fit(GAN.java:175)
    at io.skymind.example.MnistSimpleGAN.main(MnistSimpleGAN.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.nd4j.linalg.api.ops.impl.transforms.floating.Histogram
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 18 more

那么有什么问题以及如何使 localhost:9000 仪表板为此工作?

当我尝试仅观察生成器时,我在 localhost:9000 上得到了空仪表板

在此处输入图像描述

pom.xml 中的 UI 版本是

       <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-ui_2.10</artifactId>
            <version>1.0.0-beta4</version>
        </dependency> 

而其他依赖项是:

<dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>nd4j-native-platform</artifactId>
        <version>1.0.0-beta3</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>1.0.0-beta3</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.25</version>
    </dependency>

UPD。尝试使 UI 侦听 gan 网络时,将所有切换到 beta3 会出现此错误:

Exception in thread "main" java.lang.RuntimeException: org.nd4j.shade.jackson.databind.JsonMappingException: Type id handling not implemented for type java.lang.Object (through reference chain: org.deeplearning4j.nn.conf.MultiLayerConfiguration["inputPreProcessors"]->java.util.HashMap["0"])
4

0 回答 0