| | |
| | | if(l.type == CONVOLUTIONAL){ |
| | | int num = l.n*l.c*l.size*l.size; |
| | | axpy_cpu(l.n, 1, l.biases, 1, out.biases, 1); |
| | | axpy_cpu(num, 1, l.filters, 1, out.filters, 1); |
| | | axpy_cpu(num, 1, l.weights, 1, out.weights, 1); |
| | | } |
| | | if(l.type == CONNECTED){ |
| | | axpy_cpu(l.outputs, 1, l.biases, 1, out.biases, 1); |
| | |
| | | if(l.type == CONVOLUTIONAL){ |
| | | int num = l.n*l.c*l.size*l.size; |
| | | scal_cpu(l.n, 1./n, l.biases, 1); |
| | | scal_cpu(num, 1./n, l.filters, 1); |
| | | scal_cpu(num, 1./n, l.weights, 1); |
| | | } |
| | | if(l.type == CONNECTED){ |
| | | scal_cpu(l.outputs, 1./n, l.biases, 1); |
| | |
| | | save_weights_upto(net, outfile, max); |
| | | } |
| | | |
| | | void stacked(char *cfgfile, char *weightfile, char *outfile) |
| | | { |
| | | gpu_index = -1; |
| | | network net = parse_network_cfg(cfgfile); |
| | | if(weightfile){ |
| | | load_weights(&net, weightfile); |
| | | } |
| | | net.seen = 0; |
| | | save_weights_double(net, outfile); |
| | | } |
| | | |
| | | #include "convolutional_layer.h" |
| | | void rescale_net(char *cfgfile, char *weightfile, char *outfile) |
| | | { |
| | |
| | | for(i = 0; i < net.n; ++i){ |
| | | layer l = net.layers[i]; |
| | | if(l.type == CONVOLUTIONAL){ |
| | | rescale_filters(l, 2, -.5); |
| | | rescale_weights(l, 2, -.5); |
| | | break; |
| | | } |
| | | } |
| | |
| | | for(i = 0; i < net.n; ++i){ |
| | | layer l = net.layers[i]; |
| | | if(l.type == CONVOLUTIONAL){ |
| | | rgbgr_filters(l); |
| | | rgbgr_weights(l); |
| | | break; |
| | | } |
| | | } |
| | |
| | | save_weights(net, outfile); |
| | | } |
| | | |
| | | void statistics_net(char *cfgfile, char *weightfile) |
| | | { |
| | | gpu_index = -1; |
| | | network net = parse_network_cfg(cfgfile); |
| | | if (weightfile) { |
| | | load_weights(&net, weightfile); |
| | | } |
| | | int i; |
| | | for (i = 0; i < net.n; ++i) { |
| | | layer l = net.layers[i]; |
| | | if (l.type == CONNECTED && l.batch_normalize) { |
| | | printf("Connected Layer %d\n", i); |
| | | statistics_connected_layer(l); |
| | | } |
| | | if (l.type == GRU && l.batch_normalize) { |
| | | printf("GRU Layer %d\n", i); |
| | | printf("Input Z\n"); |
| | | statistics_connected_layer(*l.input_z_layer); |
| | | printf("Input R\n"); |
| | | statistics_connected_layer(*l.input_r_layer); |
| | | printf("Input H\n"); |
| | | statistics_connected_layer(*l.input_h_layer); |
| | | printf("State Z\n"); |
| | | statistics_connected_layer(*l.state_z_layer); |
| | | printf("State R\n"); |
| | | statistics_connected_layer(*l.state_r_layer); |
| | | printf("State H\n"); |
| | | statistics_connected_layer(*l.state_h_layer); |
| | | } |
| | | printf("\n"); |
| | | } |
| | | } |
| | | |
| | | void denormalize_net(char *cfgfile, char *weightfile, char *outfile) |
| | | { |
| | | gpu_index = -1; |
| | |
| | | gpu_index = -1; |
| | | #else |
| | | if(gpu_index >= 0){ |
| | | cudaError_t status = cudaSetDevice(gpu_index); |
| | | check_error(status); |
| | | cuda_set_device(gpu_index); |
| | | } |
| | | #endif |
| | | |
| | |
| | | reset_normalize_net(argv[2], argv[3], argv[4]); |
| | | } else if (0 == strcmp(argv[1], "denormalize")){ |
| | | denormalize_net(argv[2], argv[3], argv[4]); |
| | | } else if (0 == strcmp(argv[1], "statistics")){ |
| | | statistics_net(argv[2], argv[3]); |
| | | } else if (0 == strcmp(argv[1], "normalize")){ |
| | | normalize_net(argv[2], argv[3], argv[4]); |
| | | } else if (0 == strcmp(argv[1], "rescale")){ |
| | |
| | | partial(argv[2], argv[3], argv[4], atoi(argv[5])); |
| | | } else if (0 == strcmp(argv[1], "average")){ |
| | | average(argc, argv); |
| | | } else if (0 == strcmp(argv[1], "stacked")){ |
| | | stacked(argv[2], argv[3], argv[4]); |
| | | } else if (0 == strcmp(argv[1], "visualize")){ |
| | | visualize(argv[2], (argc > 3) ? argv[3] : 0); |
| | | } else if (0 == strcmp(argv[1], "imtest")){ |