diff --git a/Leecode/src/main/java/com/markilue/leecode/array/second/T03_MinSubArrayLen.java b/Leecode/src/main/java/com/markilue/leecode/array/second/T03_MinSubArrayLen.java new file mode 100644 index 0000000..683d247 --- /dev/null +++ b/Leecode/src/main/java/com/markilue/leecode/array/second/T03_MinSubArrayLen.java @@ -0,0 +1,64 @@ +package com.markilue.leecode.array.second; + +import org.junit.Test; + +/** + *@BelongsProject: Leecode + *@BelongsPackage: com.markilue.leecode.array.second + *@Author: dingjiawen + *@CreateTime: 2022-12-23 10:16 + *@Description: + *TODO 二次做209题 长度最小的子数组: + * 给定一个含有 n 个正整数的数组和一个正整数 target 。 + * 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl+1, ..., numsr-1, numsr] ,并返回其长度。如果不存在符合条件的子数组,返回 0 。 + *@Version: 1.0 + */ +public class T03_MinSubArrayLen { + + @Test + public void test(){ + int target = 7; + int[] nums = {2, 3, 1, 2, 4, 3}; + System.out.println(minSubArrayLen(target,nums)); + } + + @Test + public void test1(){ + int target = 7; + int[] nums = {1, 7, 7}; + System.out.println(minSubArrayLen(target,nums)); + } + + @Test + public void test2(){ + int target = 7; + int[] nums = {1, 1, 1}; + System.out.println(minSubArrayLen(target,nums)); + } + + + /** + * 思路:构造一个滑动窗口一直往后滑,滑动窗口刚好小于等于target + * @param target + * @param nums + * @return + */ + public int minSubArrayLen(int target, int[] nums) { + + int start=0;//窗口的开始 + int windowSum=0;//窗口数值总和 + int result=Integer.MAX_VALUE; + + for (int end = 0; end < nums.length; end++) { + windowSum+=nums[end]; + while (windowSum>=target){ + result=Math.min(result,end-start+1); + windowSum-=nums[start]; + start++; + } + } + + return result==Integer.MAX_VALUE?0:result; + + } +} diff --git a/Leecode/src/main/java/com/markilue/leecode/array/second/T04_generateMatrix.java b/Leecode/src/main/java/com/markilue/leecode/array/second/T04_generateMatrix.java new file mode 100644 index 0000000..c9bb030 --- /dev/null +++ b/Leecode/src/main/java/com/markilue/leecode/array/second/T04_generateMatrix.java @@ -0,0 +1,63 @@ +package com.markilue.leecode.array.second; + +import org.junit.Test; + +import java.util.Arrays; + +/** + *@BelongsProject: Leecode + *@BelongsPackage: com.markilue.leecode.array.second + *@Author: dingjiawen + *@CreateTime: 2022-12-23 10:30 + *@Description: + * TODO 二次做59题 螺旋数组II: + * 给你一个正整数 n ,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix + *@Version: 1.0 + */ +public class T04_generateMatrix { + + @Test + public void test(){ + int n=5; + int[][] result = generateMatrix(n); + for (int i = 0; i < n; i++) { + System.out.println(Arrays.toString(result[i])); + } + } + + + /** + * 本质上就是寻找循环不变量 + * @param n + * @return + */ + public int[][] generateMatrix(int n) { + + int[][] result = new int[n][n]; + int count = 1; + + //转几圈 + for (int i = 0; i < n / 2; i++) { + //从左往右;从上到下;从右往左;从下上到上; + int leftIndex = i; + int rightIndex = i; + for (; rightIndex < n - i-1; rightIndex++) { + result[leftIndex][rightIndex] = count++; + } + for (; leftIndex < n - i-1; leftIndex++) { + result[leftIndex][rightIndex] = count++; + } + for (; rightIndex > i; rightIndex--) { + result[leftIndex][rightIndex] = count++; + } + for (; leftIndex > i; leftIndex--) { + result[leftIndex][rightIndex] = count++; + } + } + if(n%2==1){ + result[n/2][n/2]=count; + } + + return result; + } +} diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/ListNode.java b/Leecode/src/main/java/com/markilue/leecode/listnode/ListNode.java new file mode 100644 index 0000000..30d79c7 --- /dev/null +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/ListNode.java @@ -0,0 +1,24 @@ +package com.markilue.leecode.listnode; + +/** + *@BelongsProject: Leecode + *@BelongsPackage: com.markilue.leecode.listnode + *@Author: dingjiawen + *@CreateTime: 2022-12-23 10:52 + *@Description: TODO 链表基础接口 + *@Version: 1.0 + */ +public class ListNode { + + public int val; + public ListNode next; + + public ListNode(){} + public ListNode(int val){ + this.val=val; + } + public ListNode(int val,ListNode next){ + this.val=val; + this.next=next; + } +} diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/ListNodeUtils.java b/Leecode/src/main/java/com/markilue/leecode/listnode/ListNodeUtils.java index 4c9cf52..792292a 100644 --- a/Leecode/src/main/java/com/markilue/leecode/listnode/ListNodeUtils.java +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/ListNodeUtils.java @@ -19,7 +19,6 @@ public class ListNodeUtils { int[] nodeList= {2, 4, 3}; ListNode root = build(nodeList); print(root); -// print(); } /** @@ -28,6 +27,7 @@ public class ListNodeUtils { * @return */ public static ListNode build(int[] nodeList){ + if(nodeList.length==0||nodeList==null)return null; ListNode root =new ListNode(nodeList[0]); ListNode temp=root; for (int i = 1; i < nodeList.length; i++) { diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/RemoveElement.java b/Leecode/src/main/java/com/markilue/leecode/listnode/T01_RemoveElement.java similarity index 99% rename from Leecode/src/main/java/com/markilue/leecode/listnode/RemoveElement.java rename to Leecode/src/main/java/com/markilue/leecode/listnode/T01_RemoveElement.java index 0f95961..6dd6024 100644 --- a/Leecode/src/main/java/com/markilue/leecode/listnode/RemoveElement.java +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/T01_RemoveElement.java @@ -6,7 +6,7 @@ import org.junit.Test; * 移除链表元素: * 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。 */ -public class RemoveElement { +public class T01_RemoveElement { @Test diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/MyLinkedList.java b/Leecode/src/main/java/com/markilue/leecode/listnode/T02_MyLinkedList.java similarity index 96% rename from Leecode/src/main/java/com/markilue/leecode/listnode/MyLinkedList.java rename to Leecode/src/main/java/com/markilue/leecode/listnode/T02_MyLinkedList.java index 257ae3c..d901c35 100644 --- a/Leecode/src/main/java/com/markilue/leecode/listnode/MyLinkedList.java +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/T02_MyLinkedList.java @@ -22,11 +22,11 @@ import org.junit.Test; * obj.addAtIndex(index,val); * obj.deleteAtIndex(index); */ -public class MyLinkedList { +public class T02_MyLinkedList { public ListNode head; - public MyLinkedList() { + public T02_MyLinkedList() { } @@ -163,7 +163,7 @@ public class MyLinkedList { @Test public void test(){ - MyLinkedList linkedList = new MyLinkedList(); + T02_MyLinkedList linkedList = new T02_MyLinkedList(); linkedList.addAtHead(1); printList(linkedList.head); System.out.println(); @@ -185,7 +185,7 @@ public class MyLinkedList { } @Test public void test1(){ - MyLinkedList linkedList = new MyLinkedList(); + T02_MyLinkedList linkedList = new T02_MyLinkedList(); linkedList.addAtHead(7); printList(linkedList.head); @@ -231,7 +231,7 @@ public class MyLinkedList { } @Test public void test2(){ - MyLinkedList linkedList = new MyLinkedList(); + T02_MyLinkedList linkedList = new T02_MyLinkedList(); linkedList.addAtHead(2); printList(linkedList.head); @@ -269,7 +269,7 @@ public class MyLinkedList { @Test public void test3(){ - MyLinkedList linkedList = new MyLinkedList(); + T02_MyLinkedList linkedList = new T02_MyLinkedList(); linkedList.addAtHead(1); printList(linkedList.head); diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/MyLinkedList1.java b/Leecode/src/main/java/com/markilue/leecode/listnode/T02_MyLinkedList1.java similarity index 92% rename from Leecode/src/main/java/com/markilue/leecode/listnode/MyLinkedList1.java rename to Leecode/src/main/java/com/markilue/leecode/listnode/T02_MyLinkedList1.java index e022842..5810681 100644 --- a/Leecode/src/main/java/com/markilue/leecode/listnode/MyLinkedList1.java +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/T02_MyLinkedList1.java @@ -22,13 +22,13 @@ import org.junit.Test; * obj.addAtIndex(index,val); * obj.deleteAtIndex(index); */ -public class MyLinkedList1 { +public class T02_MyLinkedList1 { //该head为虚拟节点,不存放任何数据 public ListNode head; public int size; - public MyLinkedList1() { + public T02_MyLinkedList1() { head = new ListNode(0); size = 0; } @@ -122,7 +122,7 @@ public class MyLinkedList1 { @Test public void test() { - MyLinkedList1 linkedList = new MyLinkedList1(); + T02_MyLinkedList1 linkedList = new T02_MyLinkedList1(); linkedList.addAtHead(1); printList(linkedList.head); System.out.println(); @@ -145,7 +145,7 @@ public class MyLinkedList1 { @Test public void test1() { - MyLinkedList1 linkedList = new MyLinkedList1(); + T02_MyLinkedList1 linkedList = new T02_MyLinkedList1(); linkedList.addAtHead(7); printList(linkedList.head); @@ -192,7 +192,7 @@ public class MyLinkedList1 { @Test public void test2() { - MyLinkedList1 linkedList = new MyLinkedList1(); + T02_MyLinkedList1 linkedList = new T02_MyLinkedList1(); linkedList.addAtHead(2); printList(linkedList.head); @@ -230,7 +230,7 @@ public class MyLinkedList1 { @Test public void test3() { - MyLinkedList1 linkedList = new MyLinkedList1(); + T02_MyLinkedList1 linkedList = new T02_MyLinkedList1(); linkedList.addAtHead(1); printList(linkedList.head); @@ -254,7 +254,7 @@ public class MyLinkedList1 { @Test public void test4() { - MyLinkedList1 linkedList = new MyLinkedList1(); + T02_MyLinkedList1 linkedList = new T02_MyLinkedList1(); linkedList.addAtHead(4); printList(linkedList.head); @@ -295,19 +295,3 @@ public class MyLinkedList1 { */ } -class ListNode { - public int val; - public ListNode next; - - public ListNode() { - } - - public ListNode(int val) { - this.val = val; - } - - public ListNode(int val, ListNode next) { - this.val = val; - this.next = next; - } -} diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/ReverseList.java b/Leecode/src/main/java/com/markilue/leecode/listnode/T03_ReverseList.java similarity index 98% rename from Leecode/src/main/java/com/markilue/leecode/listnode/ReverseList.java rename to Leecode/src/main/java/com/markilue/leecode/listnode/T03_ReverseList.java index bb5ace0..7a58aef 100644 --- a/Leecode/src/main/java/com/markilue/leecode/listnode/ReverseList.java +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/T03_ReverseList.java @@ -10,7 +10,7 @@ import org.junit.Test; * @Description: TODO leecode第206题,翻转链表:给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。 * @Version: 1.0 */ -public class ReverseList { +public class T03_ReverseList { @Test diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/second/T01_RemoveElement.java b/Leecode/src/main/java/com/markilue/leecode/listnode/second/T01_RemoveElement.java new file mode 100644 index 0000000..bbbaeb7 --- /dev/null +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/second/T01_RemoveElement.java @@ -0,0 +1,128 @@ +package com.markilue.leecode.listnode.second; + + +import com.markilue.leecode.listnode.ListNode; +import com.markilue.leecode.listnode.ListNodeUtils; +import org.junit.Test; + +import java.util.List; + +/** + *@BelongsProject: Leecode + *@BelongsPackage: com.markilue.leecode.listnode.second + *@Author: dingjiawen + *@CreateTime: 2022-12-23 10:50 + *@Description: + * TODO 二刷 力扣203题 移除链表元素: + * 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。 + *@Version: 1.0 + */ +public class T01_RemoveElement { + + @Test + public void test(){ + int[] head={1,2,6,3,4,5,6}; + int val=6; + ListNode root = ListNodeUtils.build(head); + ListNodeUtils.print(removeElements(root, val)); + } + + @Test + public void test1(){ + int[] head={}; + int val=6; + ListNode root = ListNodeUtils.build(head); + ListNodeUtils.print(removeElements(root, val)); + } + + @Test + public void test2(){ + int[] head={6,6,6,6,6}; + int val=6; + ListNode root = ListNodeUtils.build(head); + ListNodeUtils.print(removeElements(root, val)); + } + + + /** + * 速度击败51.77%,内存击败20.51% 1ms + * @param head + * @param val + * @return + */ + public ListNode removeElements(ListNode head, int val) { + ListNode root =new ListNode(); + root.next=head; + + ListNode temp=root; + + while (temp.next!=null){ + while (temp.next!=null&&temp.next.val==val){ + temp.next=temp.next.next; + } + if(temp.next!=null){ + temp=temp.next; + } + + } + + return root.next; + + } + + + /** + * 官方题解中最快:看起来比本人快在少了一个判断,但是对于头结点的处理不如本人 + * 0ms + * @param head + * @param val + * @return + */ + public ListNode removeElements1(ListNode head, int val) { + //删除值为val的头结点 + while(head!=null && head.val == val){ + head = head.next; + } + //传入空节点或所有结点都被删除,返回null + if(head == null)return null; + //用cur表示可能要删除的节点的前序节点 + ListNode cur = head; + + while(cur.next != null){ + //删除元素后,未遍历的新节点cur.next的前序节点还是cur + if(cur.next.val == val){ + cur.next = cur.next.next; + //仅当cur.next.val != val时,才能遍历下1个节点 + }else{ + cur = cur.next; + } + } + return head; + } + + /** + * 根据官方题解的修改: + * 0ms + * @param head + * @param val + * @return + */ + public ListNode removeElements2(ListNode head, int val) { + ListNode root =new ListNode(); + root.next=head; + + ListNode temp=root; + + while (temp.next!=null){ + //改为if以后少判断一次,因为近来就会判断一次 + if (temp.next.val==val){ + temp.next=temp.next.next; + }else { + temp=temp.next; + } + } + + return root.next; + + } +} diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/second/T02_MyLinkedList.java b/Leecode/src/main/java/com/markilue/leecode/listnode/second/T02_MyLinkedList.java new file mode 100644 index 0000000..c050467 --- /dev/null +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/second/T02_MyLinkedList.java @@ -0,0 +1,259 @@ +package com.markilue.leecode.listnode.second; + +import com.markilue.leecode.listnode.ListNode; +import org.junit.Test; + +import javax.print.DocFlavor; + +/** + *@BelongsProject: Leecode + *@BelongsPackage: com.markilue.leecode.listnode.second + *@Author: dingjiawen + *@CreateTime: 2022-12-23 11:20 + *@Description: + * TODO 二刷707题 设计链表: + * 设计链表的实现。您可以选择使用单链表或双链表。单链表中的节点应该具有两个属性:val 和 next。 + * val 是当前节点的值,next 是指向下一个节点的指针/引用。 + * 如果要使用双向链表,则还需要一个属性 prev 以指示链表中的上一个节点。 + * 假设链表中的所有节点都是 0-index 的。 + * 在链表类中实现这些功能: + * get(index):获取链表中第 index 个节点的值。如果索引无效,则返回-1。 + * addAtHead(val):在链表的第一个元素之前添加一个值为 val 的节点。插入后,新节点将成为链表的第一个节点。 + * addAtTail(val):将值为 val 的节点追加到链表的最后一个元素。 + * addAtIndex(index,val):在链表中的第 index 个节点之前添加值为 val 的节点。如果 index 等于链表的长度,则该节点将附加到链表的末尾。如果 index 大于链表长度,则不会插入节点。如果index小于0,则在头部插入节点。 + * deleteAtIndex(index):如果索引 index 有效,则删除链表中的第 index 个节点。 + *@Version: 1.0 + */ +public class T02_MyLinkedList { + + //创建的虚拟头结点 + ListNode root; + int size; + + public T02_MyLinkedList() { + this.root = new ListNode(); + this.size=0; + } + + public int get(int index) { + if(index<0||index>size-1){ + return -1; + } + int find = 0; + ListNode temp = root.next; + while (find != index && temp != null) { + temp=temp.next; + find++; + } + + if(find==index){ + //找到了 + return temp.val; + }else { + //找不到 + return -1; + } + + } + + public void addAtHead(int val) { + ListNode listNode = new ListNode(val); + listNode.next = root.next; + root.next = listNode; + size++; + } + + public void addAtTail(int val) { + ListNode temp = root; + while (temp.next != null) { + temp = temp.next; + } + temp.next = new ListNode(val); + size++; + } + + public void addAtIndex(int index, int val) { + if(index<0){ + addAtHead(val); + return; + }else if(index==size){ + addAtTail(val); + return; + } + int find=0; + ListNode temp=root; + + while (find!=index&&temp.next!=null){ + temp=temp.next; + find++; + } + //找到就插了 + if(find==index){ + ListNode listNode = new ListNode(val); + listNode.next=temp.next; + temp.next=listNode; + size++; + } + + } + + public void deleteAtIndex(int index) { + if(index<0||index>size-1){ + return; + } + int find=0; + ListNode temp=root; + + while (find!=index&&temp.next!=null){ + temp=temp.next; + find++; + } + //找没找到都要插了 + if(find==index){ + temp.next=temp.next.next; + size--; + } + + } + + @Test + public void test(){ + T02_MyLinkedList linkedList = new T02_MyLinkedList(); + linkedList.addAtHead(1); + linkedList.addAtTail(3); + linkedList.addAtIndex(1,2); //链表变为1-> 2-> 3 + System.out.println(linkedList.get(1)); + linkedList.deleteAtIndex(1); //现在链表是1-> 3 + System.out.println(linkedList.get(1)); + } + + @Test + public void test1(){ + T02_MyLinkedList linkedList = new T02_MyLinkedList(); + linkedList.addAtHead(1); + linkedList.addAtTail(3); + linkedList.addAtIndex(3,2); //链表变为1-> 2-> 3 + System.out.println(linkedList.get(1)); + linkedList.deleteAtIndex(-1); //现在链表是1-> 3 + System.out.println(linkedList.get(1)); + } + +} + + +/** + * 双向队列 + */ +class MyLinkedList { + int size; + BiListNode head; + BiListNode tail; + + public MyLinkedList() { + size = 0; + head = new BiListNode(0); + tail = new BiListNode(0); + head.next = tail; + tail.prev = head; + } + + public int get(int index) { + if (index < 0 || index >= size) { + return -1; + } + BiListNode curr; + //看看用头开始快还是用尾开始快 + if (index + 1 < size - index) { + curr = head; + for (int i = 0; i <= index; i++) { + curr = curr.next; + } + } else { + curr = tail; + for (int i = 0; i < size - index; i++) { + curr = curr.prev; + } + } + return curr.val; + } + + public void addAtHead(int val) { + addAtIndex(0, val); + } + + public void addAtTail(int val) { + addAtIndex(size, val); + } + + public void addAtIndex(int index, int val) { + if (index > size) { + return; + } + index = Math.max(0, index); + BiListNode pred, succ; + if (index < size - index) { + pred = head; + for (int i = 0; i < index; i++) { + pred = pred.next; + } + succ = pred.next; + } else { + succ = tail; + for (int i = 0; i < size - index; i++) { + succ = succ.prev; + } + pred = succ.prev; + } + size++; + BiListNode toAdd = new BiListNode(val); + toAdd.prev = pred; + toAdd.next = succ; + pred.next = toAdd; + succ.prev = toAdd; + } + + public void deleteAtIndex(int index) { + if (index < 0 || index >= size) { + return; + } + BiListNode pred, succ; + if (index < size - index) { + pred = head; + for (int i = 0; i < index; i++) { + pred = pred.next; + } + succ = pred.next.next; + } else { + succ = tail; + for (int i = 0; i < size - index - 1; i++) { + succ = succ.prev; + } + pred = succ.prev.prev; + } + size--; + pred.next = succ; + succ.prev = pred; + } +} + +class BiListNode { + int val; + BiListNode next; + BiListNode prev; + + public BiListNode(int val) { + this.val = val; + } +} + + + +/** + * Your MyLinkedList object will be instantiated and called as such: + * MyLinkedList obj = new MyLinkedList(); + * int param_1 = obj.get(index); + * obj.addAtHead(val); + * obj.addAtTail(val); + * obj.addAtIndex(index,val); + * obj.deleteAtIndex(index); + */ diff --git a/Leecode/src/main/java/com/markilue/leecode/listnode/second/T03_ReverseList.java b/Leecode/src/main/java/com/markilue/leecode/listnode/second/T03_ReverseList.java new file mode 100644 index 0000000..93edf12 --- /dev/null +++ b/Leecode/src/main/java/com/markilue/leecode/listnode/second/T03_ReverseList.java @@ -0,0 +1,46 @@ +package com.markilue.leecode.listnode.second; + +import com.markilue.leecode.listnode.ListNode; +import com.markilue.leecode.listnode.ListNodeUtils; +import org.junit.Test; + +/** + *@BelongsProject: Leecode + *@BelongsPackage: com.markilue.leecode.listnode.second + *@Author: dingjiawen + *@CreateTime: 2022-12-23 12:20 + *@Description: + * TODO 二刷206题 反转链表: + * 给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。 + *@Version: 1.0 + */ +public class T03_ReverseList { + + @Test + public void test(){ + int[] head = {1, 2, 3, 4, 5 }; + ListNode root = ListNodeUtils.build(head); + ListNodeUtils.print(reverseList(root)); + } + + @Test + public void test1(){ + int[] head = {}; + ListNode root = ListNodeUtils.build(head); + ListNodeUtils.print(reverseList(root)); + } + + public ListNode reverseList(ListNode head) { + ListNode root = new ListNode(); + ListNode temp=head; + ListNode tt; + while (temp!=null){ + tt=temp.next; + temp.next=root.next; + root.next=temp; + temp=tt; + } + return root.next; + + } +} diff --git a/TensorFlow_eaxmple/Model_train_test/condition_monitoring/plot/test_plot.py b/TensorFlow_eaxmple/Model_train_test/condition_monitoring/plot/test_plot.py index 8d15dda..5530cd3 100644 --- a/TensorFlow_eaxmple/Model_train_test/condition_monitoring/plot/test_plot.py +++ b/TensorFlow_eaxmple/Model_train_test/condition_monitoring/plot/test_plot.py @@ -7,10 +7,10 @@ import numpy as np import random import pandas as pd import seaborn as sns -from condition_monitoring.data_deal.loadData import read_data -from model.Joint_Monitoring.Joint_Monitoring_banda import Joint_Monitoring -from model.Joint_Monitoring.compare.RNet_L import Joint_Monitoring as Joint_Monitoring_L -from model.Joint_Monitoring.compare.RNet_S import Joint_Monitoring as Joint_Monitoring_SE +# from condition_monitoring.data_deal.loadData import read_data +# from model.Joint_Monitoring.Joint_Monitoring_banda import Joint_Monitoring +# from model.Joint_Monitoring.compare.RNet_L import Joint_Monitoring as Joint_Monitoring_L +# from model.Joint_Monitoring.compare.RNet_S import Joint_Monitoring as Joint_Monitoring_SE import tensorflow as tf import tensorflow.keras from mpl_toolkits.axes_grid1.inset_locator import mark_inset @@ -467,16 +467,27 @@ def plot_FNR2(y_data): x_width = range(0, len(y_data)) # x2_width = [i + 0.3 for i in x_width] - plt.bar(x_width[0], y_data[0], lw=1, color=['#FAF4E1'], width=0.5 * 2 / 3, label="ResNet-18", edgecolor='black') - plt.bar(x_width[1], y_data[1], lw=1, color=['#F5E3C4'], width=0.5 * 2 / 3, label="RNet-1", edgecolor='black') - plt.bar(x_width[2], y_data[2], lw=1, color=['#EBC99D'], width=0.5 * 2 / 3, label="RNet-2", edgecolor='black') - plt.bar(x_width[3], y_data[3], lw=1, color=['#FFC79C'], width=0.5 * 2 / 3, label="RNet-3", edgecolor='black') - plt.bar(x_width[4], y_data[4], lw=1, color=['#D6E6F2'], width=0.5 * 2 / 3, label="RNet-12", edgecolor='black') - plt.bar(x_width[5], y_data[5], lw=1, color=['#B4D1E9'], width=0.5 * 2 / 3, label="RNet-13", edgecolor='black') - plt.bar(x_width[6], y_data[6], lw=1, color=['#AEB5EE'], width=0.5 * 2 / 3, label="RNet-23", edgecolor='black') + # plt.bar(x_width[0], y_data[0], lw=1, color=['#FAF4E1'], width=0.5 * 2 / 3, label="ResNet-18", edgecolor='black') + # # plt.bar(x_width[1], y_data[1], lw=1, color=['#F5E3C4'], width=0.5 * 2 / 3, label="RNet-1", edgecolor='black') + # # plt.bar(x_width[2], y_data[2], lw=1, color=['#EBC99D'], width=0.5 * 2 / 3, label="RNet-2", edgecolor='black') + # # plt.bar(x_width[3], y_data[3], lw=1, color=['#FFC79C'], width=0.5 * 2 / 3, label="RNet-3", edgecolor='black') + # plt.bar(x_width[4], y_data[4], lw=1, color=['#D6E6F2'], width=0.5 * 2 / 3, label="RNet-12", edgecolor='black') + # # plt.bar(x_width[5], y_data[5], lw=1, color=['#B4D1E9'], width=0.5 * 2 / 3, label="RNet-13", edgecolor='black') + # # plt.bar(x_width[6], y_data[6], lw=1, color=['#AEB5EE'], width=0.5 * 2 / 3, label="RNet-23", edgecolor='black') + # # plt.bar(x_width[7] + 2.0, y_data[10], lw=0.5, color=['#8085e9'], width=1, label="ResNet-18", edgecolor='black') + # # plt.bar(x_width[7], y_data[7], lw=1, color=['#D5A9FF'], width=0.5 * 2 / 3, label="ResNet-C", edgecolor='black') + # plt.bar(x_width[8], y_data[8], lw=1, color=['#E000F5'], width=0.5 * 2 / 3, label="JMNet", edgecolor='black') + + plt.bar(x_width[0], y_data[0], lw=1, color=['#AEB5EE'], width=0.5 * 2 / 3, label="ResNet-18", edgecolor='black') + plt.bar(x_width[1], y_data[1], color=['#FFFFFF'], label=" ") + plt.bar(x_width[2], y_data[2], color=['#FFFFFF'], label=" ") + plt.bar(x_width[3], y_data[3], color=['#FFFFFF'], label=" ") + plt.bar(x_width[4], y_data[4],lw=1, color=['#D5A9FF'], width=0.5 * 2 / 3, label="RNet-C", edgecolor='black') + plt.bar(x_width[5], y_data[5], color=['#FFFFFF'], label=" ") + plt.bar(x_width[6], y_data[6], color=['#FFFFFF'], label=" ") # plt.bar(x_width[7] + 2.0, y_data[10], lw=0.5, color=['#8085e9'], width=1, label="ResNet-18", edgecolor='black') - plt.bar(x_width[7], y_data[7], lw=1, color=['#D5A9FF'], width=0.5 * 2 / 3, label="ResNet-C", edgecolor='black') - plt.bar(x_width[8], y_data[8], lw=1, color=['#E000F5'], width=0.5 * 2 / 3, label="JMNet", edgecolor='black') + plt.bar(x_width[7], y_data[7], color=['#FFFFFF'], label=" ") + plt.bar(x_width[8], y_data[8],lw=1, color=['#E000F5'], width=0.5 * 2 / 3, label="JMNet", edgecolor='black') # plt.tick_params(bottom=False, top=False, left=True, right=False, direction='in', pad=1) plt.xticks([]) @@ -487,7 +498,8 @@ def plot_FNR2(y_data): plt.xlabel('Methods', fontsize=22) # plt.tight_layout() - num1, num2, num3, num4 = 0.08, 1, 3, 0 + # num1, num2, num3, num4 = 0.08, 1, 3, 0 + num1, num2, num3, num4 = 0.15, 1, 3, 0 plt.legend(bbox_to_anchor=(num1, num2), loc=num3, borderaxespad=num4, ncol=5, frameon=False, handlelength=1, handletextpad=0.45, columnspacing=1) plt.ylim([0, 5]) @@ -785,6 +797,7 @@ if __name__ == '__main__': # plot_FNR1(list) # # list=[3.43,1.99,1.92,2.17,1.63,1.81,1.78,1.8,0.6] + list=[3.43,1.99,1.92,2.17,1.8,1.81,1.78,1.8,0.6] plot_FNR2(list) # 查看网络某一层的权重